1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 // MARKER(update_precomp.py): autogen include statement, do not remove 23 #include "precompiled_svx.hxx" 24 25 #include <com/sun/star/container/XNameContainer.hpp> 26 #include "svx/XPropertyTable.hxx" 27 #include <unotools/ucbstreamhelper.hxx> 28 #include <xmlxtexp.hxx> 29 #include <xmlxtimp.hxx> 30 #include <tools/urlobj.hxx> 31 #include <vcl/virdev.hxx> 32 #include <svl/itemset.hxx> 33 #include <sfx2/docfile.hxx> 34 #include <svx/dialogs.hrc> 35 #include <svx/dialmgr.hxx> 36 #include <svx/xtable.hxx> 37 #include <svx/xpool.hxx> 38 #include <svx/xbtmpit.hxx> 39 40 #define GLOBALOVERFLOW 41 42 using namespace com::sun::star; 43 using namespace rtl; 44 45 sal_Unicode const pszExtBitmap[] = {'s','o','b'}; 46 47 static char const aChckBitmap[] = { 0x04, 0x00, 'S','O','B','L'}; // very old 48 static char const aChckBitmap0[] = { 0x04, 0x00, 'S','O','B','0'}; // old 49 static char const aChckBitmap1[] = { 0x04, 0x00, 'S','O','B','1'}; // = 5.2 50 static char const aChckXML[] = { 'P', 'K', 0x03, 0x04 }; // = 6.0 51 52 // ------------------ 53 // class XBitmapList 54 // ------------------ 55 56 XBitmapList::XBitmapList( const String& rPath ) : 57 XPropertyList( rPath ) 58 { 59 } 60 61 /************************************************************************/ 62 63 XBitmapList::~XBitmapList() 64 { 65 } 66 67 /************************************************************************/ 68 69 XBitmapEntry* XBitmapList::Replace(XBitmapEntry* pEntry, long nIndex ) 70 { 71 return (XBitmapEntry*) XPropertyList::Replace(pEntry, nIndex); 72 } 73 74 /************************************************************************/ 75 76 XBitmapEntry* XBitmapList::Remove(long nIndex) 77 { 78 return (XBitmapEntry*) XPropertyList::Remove(nIndex); 79 } 80 81 /************************************************************************/ 82 83 XBitmapEntry* XBitmapList::GetBitmap(long nIndex) const 84 { 85 return (XBitmapEntry*) XPropertyList::Get(nIndex); 86 } 87 88 /************************************************************************/ 89 90 bool XBitmapList::Load() 91 { 92 if( mbListDirty ) 93 { 94 mbListDirty = false; 95 96 INetURLObject aURL( maPath ); 97 98 if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) 99 { 100 DBG_ASSERT( !maPath.Len(), "invalid URL" ); 101 return false; 102 } 103 104 aURL.Append( maName ); 105 106 if( !aURL.getExtension().getLength() ) 107 aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) ); 108 109 uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY ); 110 return SvxXMLXTableImport::load( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); 111 } 112 113 return false; 114 } 115 116 /************************************************************************/ 117 118 bool XBitmapList::Save() 119 { 120 INetURLObject aURL( maPath ); 121 122 if( INET_PROT_NOT_VALID == aURL.GetProtocol() ) 123 { 124 DBG_ASSERT( !maPath.Len(), "invalid URL" ); 125 return false; 126 } 127 128 aURL.Append( maName ); 129 130 if( !aURL.getExtension().getLength() ) 131 aURL.setExtension( rtl::OUString( pszExtBitmap, 3 ) ); 132 133 uno::Reference< container::XNameContainer > xTable( SvxUnoXBitmapTable_createInstance( this ), uno::UNO_QUERY ); 134 return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ), xTable ); 135 } 136 137 /************************************************************************/ 138 // Umgestellt am 27.07.95 auf XBitmap 139 140 bool XBitmapList::Create() 141 { 142 String aStr(SVX_RES(RID_SVXSTR_BITMAP)); 143 sal_uInt16 aArray[64]; 144 Bitmap aBitmap; 145 const xub_StrLen nLen(aStr.Len() - 1); 146 147 memset(aArray, 0, sizeof(aArray)); 148 149 // white/white bitmap 150 aStr.AppendAscii(" 1"); 151 aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_WHITE), RGB_Color(COL_WHITE)); 152 Insert(new XBitmapEntry(Graphic(aBitmap), aStr)); 153 154 // black/white bitmap 155 aArray[ 0] = 1; aArray[ 9] = 1; aArray[18] = 1; aArray[27] = 1; 156 aArray[36] = 1; aArray[45] = 1; aArray[54] = 1; aArray[63] = 1; 157 aStr.SetChar(nLen, sal_Unicode('2')); 158 aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_BLACK), RGB_Color(COL_WHITE)); 159 Insert(new XBitmapEntry(Graphic(aBitmap), aStr)); 160 161 // lightred/white bitmap 162 aArray[ 7] = 1; aArray[14] = 1; aArray[21] = 1; aArray[28] = 1; 163 aArray[35] = 1; aArray[42] = 1; aArray[49] = 1; aArray[56] = 1; 164 aStr.SetChar(nLen, sal_Unicode('3')); 165 aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_LIGHTRED), RGB_Color(COL_WHITE)); 166 Insert(new XBitmapEntry(Graphic(aBitmap), aStr)); 167 168 // lightblue/white bitmap 169 aArray[24] = 1; aArray[25] = 1; aArray[26] = 1; 170 aArray[29] = 1; aArray[30] = 1; aArray[31] = 1; 171 aStr.SetChar(nLen, sal_Unicode('4')); 172 aBitmap = createHistorical8x8FromArray(aArray, RGB_Color(COL_LIGHTBLUE), RGB_Color(COL_WHITE)); 173 Insert(new XBitmapEntry(Graphic(aBitmap), aStr)); 174 175 return true; 176 } 177 178 /************************************************************************/ 179 180 Bitmap XBitmapList::CreateBitmapForUI( long /*nIndex*/ ) 181 { 182 return Bitmap(); 183 } 184 185 // eof 186