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_sd.hxx" 24 25 #include <com/sun/star/lang/DisposedException.hpp> 26 #include <com/sun/star/presentation/ClickAction.hpp> 27 #include <com/sun/star/presentation/FadeEffect.hpp> 28 #include <com/sun/star/presentation/AnimationEffect.hpp> 29 #include <com/sun/star/presentation/PresentationRange.hpp> 30 #include <com/sun/star/presentation/AnimationSpeed.hpp> 31 #include <com/sun/star/view/PaperOrientation.hpp> 32 #include <com/sun/star/animations/AnimationNodeType.hpp> 33 #include <com/sun/star/presentation/EffectNodeType.hpp> 34 #include <com/sun/star/lang/DisposedException.hpp> 35 #include <comphelper/processfactory.hxx> 36 #include <rtl/ustrbuf.hxx> 37 #include <vcl/bitmapex.hxx> 38 #include <vcl/metaact.hxx> 39 #include <toolkit/helper/vclunohelper.hxx> 40 #include <vcl/svapp.hxx> 41 #include <vcl/settings.hxx> 42 #include <unomodel.hxx> 43 #include <unopage.hxx> 44 #include <svx/svxids.hrc> 45 #include <svl/itemset.hxx> 46 #include <svx/svdmodel.hxx> 47 #include <sdresid.hxx> 48 #include <glob.hrc> 49 #include <sdpage.hxx> 50 #include <unoprnms.hxx> 51 #include <sdattr.hxx> 52 #include <drawdoc.hxx> 53 #include <svx/unoshape.hxx> 54 #include <com/sun/star/style/XStyle.hpp> 55 #include <svx/svdorect.hxx> 56 #include <vos/mutex.hxx> 57 #include <svl/style.hxx> 58 #include <rtl/uuid.h> 59 #include <rtl/memory.h> 60 #include <comphelper/serviceinfohelper.hxx> 61 #include <comphelper/extract.hxx> 62 #include <list> 63 #include <svx/svditer.hxx> 64 #include <svtools/wmf.hxx> 65 #include <svx/svdoole2.hxx> 66 #include <svx/svdpool.hxx> 67 #include <svx/svdview.hxx> 68 #include "misc.hxx" 69 #include "View.hxx" 70 #include "DrawDocShell.hxx" 71 #include "ViewShell.hxx" 72 #include "DrawViewShell.hxx" 73 #include "unoobj.hxx" 74 #include "res_bmp.hrc" 75 #include "unokywds.hxx" 76 #include "unopback.hxx" 77 #include "unohelp.hxx" 78 #include <vcl/dibtools.hxx> 79 #include <svx/svdograf.hxx> 80 81 using ::com::sun::star::animations::XAnimationNode; 82 using ::com::sun::star::animations::XAnimationNodeSupplier; 83 using ::rtl::OUString; 84 using ::rtl::OUStringBuffer; 85 86 using namespace ::vos; 87 using namespace ::osl; 88 using namespace ::com::sun::star; 89 using namespace ::com::sun::star::uno; 90 using namespace ::com::sun::star::lang; 91 using namespace ::com::sun::star::container; 92 using namespace ::com::sun::star::drawing; 93 using namespace ::com::sun::star::office; 94 95 namespace sd { 96 extern Reference< XAnnotation > createAnnotation( const Reference< XComponentContext >& xContext, SdPage* ); 97 extern Reference< XAnnotationEnumeration > createAnnotationEnumeration( const sd::AnnotationVector& ); 98 } 99 100 /* this are the ids for page properties */ 101 enum WID_PAGE 102 { 103 WID_PAGE_LEFT, WID_PAGE_RIGHT, WID_PAGE_TOP, WID_PAGE_BOTTOM, WID_PAGE_WIDTH, 104 WID_PAGE_HEIGHT, WID_PAGE_EFFECT, WID_PAGE_CHANGE, WID_PAGE_SPEED, WID_PAGE_NUMBER, 105 WID_PAGE_ORIENT, WID_PAGE_LAYOUT, WID_PAGE_DURATION, WID_PAGE_LDNAME, WID_PAGE_LDBITMAP, 106 WID_PAGE_BACK, WID_PAGE_PREVIEW, WID_PAGE_PREVIEWBITMAP, WID_PAGE_VISIBLE, WID_PAGE_SOUNDFILE, WID_PAGE_BACKFULL, 107 WID_PAGE_BACKVIS, WID_PAGE_BACKOBJVIS, WID_PAGE_USERATTRIBS, WID_PAGE_BOOKMARK, WID_PAGE_ISDARK, 108 WID_PAGE_HEADERVISIBLE, WID_PAGE_HEADERTEXT, WID_PAGE_FOOTERVISIBLE, WID_PAGE_FOOTERTEXT, 109 WID_PAGE_PAGENUMBERVISIBLE, WID_PAGE_DATETIMEVISIBLE, WID_PAGE_DATETIMEFIXED, 110 WID_PAGE_DATETIMETEXT, WID_PAGE_DATETIMEFORMAT, WID_TRANSITION_TYPE, WID_TRANSITION_SUBTYPE, 111 WID_TRANSITION_DIRECTION, WID_TRANSITION_FADE_COLOR, WID_TRANSITION_DURATION, WID_LOOP_SOUND, 112 WID_NAVORDER 113 }; 114 115 #ifndef SEQTYPE 116 #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500) 117 #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x )) 118 #else 119 #define SEQTYPE(x) &(x) 120 #endif 121 #endif 122 123 static sal_Char __FAR_DATA sEmptyPageName[sizeof("page")] = "page"; 124 125 /** this function stores the property maps for draw pages in impress and draw */ 126 const SvxItemPropertySet* ImplGetDrawPagePropertySet( sal_Bool bImpress, PageKind ePageKind ) 127 { 128 static const SfxItemPropertyMapEntry aDrawPagePropertyMap_Impl[] = 129 { 130 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE( beans::XPropertySet ), beans::PropertyAttribute::MAYBEVOID,0}, 131 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, 132 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, 133 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, 134 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, 135 { MAP_CHAR_LEN(UNO_NAME_PAGE_CHANGE), WID_PAGE_CHANGE, &::getCppuType((const sal_Int32*)0), 0, 0}, 136 { MAP_CHAR_LEN(UNO_NAME_PAGE_DURATION), WID_PAGE_DURATION, &::getCppuType((const sal_Int32*)0), 0, 0}, 137 { MAP_CHAR_LEN(UNO_NAME_PAGE_EFFECT), WID_PAGE_EFFECT, &::getCppuType((const presentation::FadeEffect*)0), 0, 0}, 138 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, 139 { MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, &::getCppuType((const sal_Int16*)0), 0, 0}, 140 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE( awt::XBitmap), beans::PropertyAttribute::READONLY, 0}, 141 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0}, 142 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, 143 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, 144 { MAP_CHAR_LEN(UNO_NAME_PAGE_SPEED), WID_PAGE_SPEED, &::getCppuType((const presentation::AnimationSpeed*)0), 0, 0}, 145 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, 146 { MAP_CHAR_LEN(UNO_NAME_PAGE_PREVIEW), WID_PAGE_PREVIEW, SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, 147 { MAP_CHAR_LEN(UNO_NAME_PAGE_PREVIEWBITMAP), WID_PAGE_PREVIEWBITMAP, SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, 148 { MAP_CHAR_LEN(UNO_NAME_PAGE_VISIBLE), WID_PAGE_VISIBLE, &::getBooleanCppuType(), 0, 0}, 149 { MAP_CHAR_LEN(UNO_NAME_OBJ_SOUNDFILE), WID_PAGE_SOUNDFILE, &::getCppuType((const Any*)0), 0, 0}, 150 { MAP_CHAR_LEN(sUNO_Prop_IsBackgroundVisible), WID_PAGE_BACKVIS, &::getBooleanCppuType(), 0, 0}, 151 { MAP_CHAR_LEN(sUNO_Prop_IsBackgroundObjectsVisible), WID_PAGE_BACKOBJVIS, &::getBooleanCppuType(), 0, 0}, 152 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 153 { MAP_CHAR_LEN(sUNO_Prop_BookmarkURL), WID_PAGE_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0}, 154 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, 155 { MAP_CHAR_LEN("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(), 0, 0}, 156 { MAP_CHAR_LEN("FooterText"), WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0), 0, 0}, 157 { MAP_CHAR_LEN("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(), 0, 0}, 158 { MAP_CHAR_LEN("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(), 0, 0}, 159 { MAP_CHAR_LEN("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(), 0, 0}, 160 { MAP_CHAR_LEN("DateTimeText"), WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0), 0, 0}, 161 { MAP_CHAR_LEN("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0), 0, 0}, 162 { MAP_CHAR_LEN("TransitionType"), WID_TRANSITION_TYPE, &::getCppuType((const sal_Int16*)0), 0, 0}, 163 { MAP_CHAR_LEN("TransitionSubtype"), WID_TRANSITION_SUBTYPE, &::getCppuType((const sal_Int16*)0), 0, 0}, 164 { MAP_CHAR_LEN("TransitionDirection"), WID_TRANSITION_DIRECTION, &::getCppuType((const sal_Bool*)0), 0, 0}, 165 { MAP_CHAR_LEN("TransitionFadeColor"), WID_TRANSITION_FADE_COLOR, &::getCppuType((const sal_Int32*)0), 0, 0}, 166 { MAP_CHAR_LEN("TransitionDuration"), WID_TRANSITION_DURATION, &::getCppuType((const double*)0), 0, 0}, 167 { MAP_CHAR_LEN("LoopSound"), WID_LOOP_SOUND, &::getBooleanCppuType(), 0, 0}, 168 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::com::sun::star::container::XIndexAccess::static_type(),0, 0}, 169 {0,0,0,0,0,0} 170 }; 171 172 #define DRAW_PAGE_NOTES_PROPERTIES \ 173 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 174 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 175 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 176 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 177 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 178 { MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, &::getCppuType((const sal_Int16*)0), 0, 0}, \ 179 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE( awt::XBitmap), beans::PropertyAttribute::READONLY, 0}, \ 180 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0}, \ 181 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, \ 182 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, \ 183 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 184 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0},\ 185 { MAP_CHAR_LEN("IsHeaderVisible"), WID_PAGE_HEADERVISIBLE, &::getBooleanCppuType(), 0, 0}, \ 186 { MAP_CHAR_LEN("HeaderText"), WID_PAGE_HEADERTEXT, &::getCppuType((const OUString*)0), 0, 0}, \ 187 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, \ 188 { MAP_CHAR_LEN("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(), 0, 0}, \ 189 { MAP_CHAR_LEN("FooterText"), WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0), 0, 0}, \ 190 { MAP_CHAR_LEN("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(), 0, 0}, \ 191 { MAP_CHAR_LEN("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(), 0, 0}, \ 192 { MAP_CHAR_LEN("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(), 0, 0}, \ 193 { MAP_CHAR_LEN("DateTimeText"), WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0), 0, 0}, \ 194 { MAP_CHAR_LEN("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 195 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::com::sun::star::container::XIndexAccess::static_type(),0, 0}, \ 196 {0,0,0,0,0,0} 197 198 static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyMap_Impl[] = 199 { 200 // this must be the first two entries so they can be excluded for PK_STANDARD 201 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE( beans::XPropertySet ), beans::PropertyAttribute::MAYBEVOID,0}, 202 DRAW_PAGE_NOTES_PROPERTIES 203 }; 204 static const SfxItemPropertyMapEntry aDrawPageNotesHandoutPropertyNoBackMap_Impl[] = 205 { 206 DRAW_PAGE_NOTES_PROPERTIES 207 }; 208 209 #define GRAPHIC_PAGE_PROPERTIES \ 210 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 211 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 212 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 213 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 214 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 215 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE(awt::XBitmap), beans::PropertyAttribute::READONLY, 0}, \ 216 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0}, \ 217 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, \ 218 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, \ 219 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, \ 220 { MAP_CHAR_LEN(UNO_NAME_PAGE_PREVIEW), WID_PAGE_PREVIEW, SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0}, \ 221 { MAP_CHAR_LEN(UNO_NAME_PAGE_PREVIEWBITMAP), WID_PAGE_PREVIEWBITMAP, SEQTYPE(::getCppuType((::com::sun::star::uno::Sequence<sal_Int8>*)0)), ::com::sun::star::beans::PropertyAttribute::READONLY, 0},\ 222 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, \ 223 { MAP_CHAR_LEN(sUNO_Prop_BookmarkURL), WID_PAGE_BOOKMARK, &::getCppuType((const OUString*)0), 0, 0}, \ 224 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, \ 225 { MAP_CHAR_LEN("NavigationOrder"), WID_NAVORDER, &::com::sun::star::container::XIndexAccess::static_type(),0, 0}, \ 226 {0,0,0,0,0,0} 227 228 static const SfxItemPropertyMapEntry aGraphicPagePropertyMap_Impl[] = 229 { 230 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE( beans::XPropertySet), beans::PropertyAttribute::MAYBEVOID,0}, 231 GRAPHIC_PAGE_PROPERTIES 232 }; 233 static const SfxItemPropertyMapEntry aGraphicPagePropertyNoBackMap_Impl[] = 234 { 235 GRAPHIC_PAGE_PROPERTIES 236 }; 237 238 // 239 bool bWithoutBackground = ePageKind != PK_STANDARD && ePageKind != PK_HANDOUT; 240 const SvxItemPropertySet* pRet = 0; 241 if( bImpress ) 242 { 243 if( ePageKind == PK_STANDARD ) 244 { 245 //PK_STANDARD always has a background property 246 static SvxItemPropertySet aDrawPagePropertySet_Impl( aDrawPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 247 pRet = &aDrawPagePropertySet_Impl; 248 } 249 else 250 { 251 if(bWithoutBackground) 252 { 253 static SvxItemPropertySet aDrawPageNotesHandoutPropertyNoBackSet_Impl( aDrawPageNotesHandoutPropertyNoBackMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 254 pRet = &aDrawPageNotesHandoutPropertyNoBackSet_Impl; 255 } 256 else 257 { 258 static SvxItemPropertySet aDrawPageNotesHandoutPropertySet_Impl( aDrawPageNotesHandoutPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 259 pRet = &aDrawPageNotesHandoutPropertySet_Impl; 260 } 261 } 262 } 263 else 264 { 265 if(bWithoutBackground) 266 { 267 static SvxItemPropertySet aGraphicPagePropertyNoBackSet_Impl( aGraphicPagePropertyNoBackMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 268 pRet = &aGraphicPagePropertyNoBackSet_Impl; 269 } 270 else 271 { 272 static SvxItemPropertySet aGraphicPagePropertySet_Impl( aGraphicPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 273 pRet = &aGraphicPagePropertySet_Impl; 274 } 275 } 276 return pRet; 277 } 278 279 /** this function stores the property map for master pages in impress and draw */ 280 const SvxItemPropertySet* ImplGetMasterPagePropertySet( PageKind ePageKind ) 281 { 282 static const SfxItemPropertyMapEntry aMasterPagePropertyMap_Impl[] = 283 { 284 { MAP_CHAR_LEN(UNO_NAME_PAGE_BACKGROUND), WID_PAGE_BACK, &ITYPE(beans::XPropertySet), 0, 0}, 285 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, 286 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, 287 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, 288 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, 289 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, 290 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYBITMAP), WID_PAGE_LDBITMAP, &ITYPE(awt::XBitmap), beans::PropertyAttribute::READONLY, 0}, 291 { MAP_CHAR_LEN(UNO_NAME_LINKDISPLAYNAME), WID_PAGE_LDNAME, &::getCppuType((const OUString*)0), beans::PropertyAttribute::READONLY, 0}, 292 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, 293 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, 294 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, 295 { MAP_CHAR_LEN("BackgroundFullSize"), WID_PAGE_BACKFULL, &::getBooleanCppuType(), 0, 0}, 296 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 297 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, 298 {0,0,0,0,0,0} 299 }; 300 301 static const SfxItemPropertyMapEntry aHandoutMasterPagePropertyMap_Impl[] = 302 { 303 { MAP_CHAR_LEN(UNO_NAME_PAGE_BOTTOM), WID_PAGE_BOTTOM, &::getCppuType((const sal_Int32*)0), 0, 0}, 304 { MAP_CHAR_LEN(UNO_NAME_PAGE_LEFT), WID_PAGE_LEFT, &::getCppuType((const sal_Int32*)0), 0, 0}, 305 { MAP_CHAR_LEN(UNO_NAME_PAGE_RIGHT), WID_PAGE_RIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, 306 { MAP_CHAR_LEN(UNO_NAME_PAGE_TOP), WID_PAGE_TOP, &::getCppuType((const sal_Int32*)0), 0, 0}, 307 { MAP_CHAR_LEN(UNO_NAME_PAGE_HEIGHT), WID_PAGE_HEIGHT, &::getCppuType((const sal_Int32*)0), 0, 0}, 308 { MAP_CHAR_LEN(UNO_NAME_PAGE_ORIENTATION), WID_PAGE_ORIENT, &::getCppuType((const view::PaperOrientation*)0),0, 0}, 309 { MAP_CHAR_LEN(UNO_NAME_PAGE_NUMBER), WID_PAGE_NUMBER, &::getCppuType((const sal_Int16*)0), beans::PropertyAttribute::READONLY, 0}, 310 { MAP_CHAR_LEN(UNO_NAME_PAGE_WIDTH), WID_PAGE_WIDTH, &::getCppuType((const sal_Int32*)0), 0, 0}, 311 { MAP_CHAR_LEN(UNO_NAME_PAGE_LAYOUT), WID_PAGE_LAYOUT, &::getCppuType((const sal_Int16*)0), 0, 0}, 312 { MAP_CHAR_LEN(sUNO_Prop_UserDefinedAttributes),WID_PAGE_USERATTRIBS, &::getCppuType((const Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 313 { MAP_CHAR_LEN("IsBackgroundDark" ), WID_PAGE_ISDARK, &::getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0}, 314 { MAP_CHAR_LEN("IsHeaderVisible"), WID_PAGE_HEADERVISIBLE, &::getBooleanCppuType(), 0, 0}, 315 { MAP_CHAR_LEN("HeaderText"), WID_PAGE_HEADERTEXT, &::getCppuType((const OUString*)0), 0, 0}, 316 { MAP_CHAR_LEN("IsFooterVisible"), WID_PAGE_FOOTERVISIBLE, &::getBooleanCppuType(), 0, 0}, 317 { MAP_CHAR_LEN("FooterText"), WID_PAGE_FOOTERTEXT, &::getCppuType((const OUString*)0), 0, 0}, 318 { MAP_CHAR_LEN("IsPageNumberVisible"), WID_PAGE_PAGENUMBERVISIBLE, &::getBooleanCppuType(), 0, 0}, 319 { MAP_CHAR_LEN("IsDateTimeVisible"), WID_PAGE_DATETIMEVISIBLE, &::getBooleanCppuType(), 0, 0}, 320 { MAP_CHAR_LEN("IsDateTimeFixed"), WID_PAGE_DATETIMEFIXED, &::getBooleanCppuType(), 0, 0}, 321 { MAP_CHAR_LEN("DateTimeText"), WID_PAGE_DATETIMETEXT, &::getCppuType((const OUString*)0), 0, 0}, 322 { MAP_CHAR_LEN("DateTimeFormat"), WID_PAGE_DATETIMEFORMAT, &::getCppuType((const sal_Int32*)0), 0, 0}, 323 {0,0,0,0,0,0} 324 }; 325 326 const SvxItemPropertySet* pRet = 0; 327 if( ePageKind == PK_HANDOUT ) 328 { 329 static SvxItemPropertySet aHandoutMasterPagePropertySet_Impl( aHandoutMasterPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 330 pRet = &aHandoutMasterPagePropertySet_Impl; 331 } 332 else 333 { 334 static SvxItemPropertySet aMasterPagePropertySet_Impl( aMasterPagePropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 335 pRet = &aMasterPagePropertySet_Impl; 336 } 337 return pRet; 338 } 339 340 const ::com::sun::star::uno::Sequence< sal_Int8 > & SdGenericDrawPage::getUnoTunnelId() throw() 341 { 342 static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0; 343 if( !pSeq ) 344 { 345 ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); 346 if( !pSeq ) 347 { 348 static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 ); 349 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 350 pSeq = &aSeq; 351 } 352 } 353 return *pSeq; 354 } 355 356 sal_Int64 SAL_CALL SdGenericDrawPage::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) 357 { 358 if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 359 rId.getConstArray(), 16 ) ) 360 { 361 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); 362 } 363 else 364 { 365 return SvxFmDrawPage::getSomething( rId ); 366 } 367 } 368 369 /*********************************************************************** 370 * * 371 ***********************************************************************/ 372 SdGenericDrawPage::SdGenericDrawPage( SdXImpressDocument* _pModel, SdPage* pInPage, const SvxItemPropertySet* _pSet ) throw() 373 : SvxFmDrawPage( (SdrPage*) pInPage ), 374 SdUnoSearchReplaceShape(this), 375 mpModel ( _pModel ), 376 mpSdrModel(0), 377 mnTempPageNumber(0), 378 mpPropSet ( _pSet ), 379 mbIsImpressDocument(false) 380 { 381 mpSdrModel = SvxFmDrawPage::mpModel; 382 if( mpModel ) 383 mbIsImpressDocument = mpModel->IsImpressDocument() ? true : false; 384 385 } 386 387 SdGenericDrawPage::~SdGenericDrawPage() throw() 388 { 389 } 390 391 void SdGenericDrawPage::throwIfDisposed() const 392 { 393 if( (SvxFmDrawPage::mpModel == 0) || (mpModel == 0) || (SvxFmDrawPage::mpPage == 0) ) 394 throw lang::DisposedException(); 395 } 396 397 SdXImpressDocument* SdGenericDrawPage::GetModel() const 398 { 399 if( mpSdrModel != SvxFmDrawPage::mpModel ) 400 { 401 const_cast< SdGenericDrawPage* >(this)->mpSdrModel = SvxFmDrawPage::mpModel; 402 if( mpSdrModel ) 403 { 404 uno::Reference< uno::XInterface > xModel( SvxFmDrawPage::mpModel->getUnoModel() ); 405 const_cast< SdGenericDrawPage*>(this)->mpModel = SdXImpressDocument::getImplementation( xModel ); 406 if( mpModel ) 407 const_cast< SdGenericDrawPage*>(this)->mbIsImpressDocument = mpModel->IsImpressDocument() ? true : false; 408 } 409 else 410 { 411 const_cast< SdGenericDrawPage* >(this)->mpModel = 0; 412 } 413 } 414 415 return mpModel; 416 } 417 418 // this is called whenever a SdrObject must be created for a empty api shape wrapper 419 SdrObject * SdGenericDrawPage::_CreateSdrObject( const Reference< drawing::XShape >& xShape ) throw() 420 { 421 if( NULL == SvxFmDrawPage::mpPage || !xShape.is() ) 422 return NULL; 423 424 String aType( xShape->getShapeType() ); 425 const String aPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.") ); 426 if( aType.CompareTo( aPrefix, aPrefix.Len() ) != 0 ) 427 { 428 SdrObject* pObj = SvxFmDrawPage::_CreateSdrObject( xShape ); 429 if( pObj && ( (pObj->GetObjInventor() != SdrInventor) || (pObj->GetObjIdentifier() != OBJ_PAGE) ) ) 430 { 431 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel(); 432 if( pDoc ) 433 { 434 // #119287# similar to the code in the SdrObject methods the graphic and ole 435 // SdrObjects need another default style than the rest, see task. Adding here, too. 436 // TTTT: Same as for #119287#: Can be removed in branch aw080 again 437 const bool bIsSdrGrafObj(0 != dynamic_cast< SdrGrafObj* >(pObj)); 438 const bool bIsSdrOle2Obj(0 != dynamic_cast< SdrOle2Obj* >(pObj)); 439 440 if(bIsSdrGrafObj || bIsSdrOle2Obj) 441 { 442 pObj->NbcSetStyleSheet(pDoc->GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(), sal_True); 443 } 444 else 445 { 446 pObj->NbcSetStyleSheet(pDoc->GetDefaultStyleSheet(), sal_True); 447 } 448 } 449 } 450 return pObj; 451 } 452 453 aType = aType.Copy( aPrefix.Len() ); 454 455 PresObjKind eObjKind = PRESOBJ_NONE; 456 457 if( aType.EqualsAscii( "TitleTextShape" ) ) 458 { 459 eObjKind = PRESOBJ_TITLE; 460 } 461 else if( aType.EqualsAscii( "OutlinerShape" ) ) 462 { 463 eObjKind = PRESOBJ_OUTLINE; 464 } 465 else if( aType.EqualsAscii( "SubtitleShape" ) ) 466 { 467 eObjKind = PRESOBJ_TEXT; 468 } 469 else if( aType.EqualsAscii( "OLE2Shape" ) ) 470 { 471 eObjKind = PRESOBJ_OBJECT; 472 } 473 else if( aType.EqualsAscii( "ChartShape" ) ) 474 { 475 eObjKind = PRESOBJ_CHART; 476 } 477 else if( aType.EqualsAscii( "CalcShape" ) ) 478 { 479 eObjKind = PRESOBJ_CALC; 480 } 481 else if( aType.EqualsAscii( "TableShape" ) ) 482 { 483 eObjKind = PRESOBJ_TABLE; 484 } 485 else if( aType.EqualsAscii( "GraphicObjectShape" ) ) 486 { 487 #ifdef STARIMAGE_AVAILABLE 488 eObjKind = PRESOBJ_IMAGE; 489 #else 490 eObjKind = PRESOBJ_GRAPHIC; 491 #endif 492 } 493 else if( aType.EqualsAscii( "OrgChartShape" ) ) 494 { 495 eObjKind = PRESOBJ_ORGCHART; 496 } 497 else if( aType.EqualsAscii( "PageShape" ) ) 498 { 499 if( GetPage()->GetPageKind() == PK_NOTES && GetPage()->IsMasterPage() ) 500 eObjKind = PRESOBJ_TITLE; 501 else 502 eObjKind = PRESOBJ_PAGE; 503 } 504 else if( aType.EqualsAscii( "NotesShape" ) ) 505 { 506 eObjKind = PRESOBJ_NOTES; 507 } 508 else if( aType.EqualsAscii( "HandoutShape" ) ) 509 { 510 eObjKind = PRESOBJ_HANDOUT; 511 } 512 else if( aType.EqualsAscii( "FooterShape" ) ) 513 { 514 eObjKind = PRESOBJ_FOOTER; 515 } 516 else if( aType.EqualsAscii( "HeaderShape" ) ) 517 { 518 eObjKind = PRESOBJ_HEADER; 519 } 520 else if( aType.EqualsAscii( "SlideNumberShape" ) ) 521 { 522 eObjKind = PRESOBJ_SLIDENUMBER; 523 } 524 else if( aType.EqualsAscii( "DateTimeShape" ) ) 525 { 526 eObjKind = PRESOBJ_DATETIME; 527 } 528 else if( aType.EqualsAscii( "MediaShape" ) ) 529 { 530 eObjKind = PRESOBJ_MEDIA; 531 } 532 533 Rectangle aRect( eObjKind == PRESOBJ_TITLE ? GetPage()->GetTitleRect() : GetPage()->GetLayoutRect() ); 534 535 const awt::Point aPos( aRect.Left(), aRect.Top() ); 536 xShape->setPosition( aPos ); 537 538 const awt::Size aSize( aRect.GetWidth(), aRect.GetHeight() ); 539 xShape->setSize( aSize ); 540 541 SdrObject *pPresObj = 0; 542 if( (eObjKind == PRESOBJ_TABLE) || (eObjKind == PRESOBJ_MEDIA) ) 543 { 544 pPresObj = SvxFmDrawPage::_CreateSdrObject( xShape ); 545 if( pPresObj ) 546 { 547 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel(); 548 if( pDoc ) 549 pPresObj->NbcSetStyleSheet( pDoc->GetDefaultStyleSheet(), sal_True ); 550 GetPage()->InsertPresObj( pPresObj, eObjKind ); 551 } 552 } 553 else 554 { 555 pPresObj = GetPage()->CreatePresObj( eObjKind, sal_False, aRect, sal_True ); 556 } 557 558 if( pPresObj ) 559 pPresObj->SetUserCall( GetPage() ); 560 561 return pPresObj; 562 } 563 564 // XInterface 565 Any SAL_CALL SdGenericDrawPage::queryInterface( const uno::Type & rType ) 566 { 567 Any aAny; 568 569 QUERYINT( beans::XPropertySet ); 570 else QUERYINT( container::XNamed ); 571 else QUERYINT( util::XReplaceable ); 572 else QUERYINT( util::XSearchable ); 573 else QUERYINT( document::XLinkTargetSupplier ); 574 else QUERYINT( drawing::XShapeCombiner ); 575 else QUERYINT( drawing::XShapeBinder ); 576 else QUERYINT( beans::XMultiPropertySet ); 577 else if( rType == ITYPE( office::XAnnotationAccess ) ) 578 { 579 return Any( Reference< office::XAnnotationAccess >( this ) ); 580 } 581 else if( rType == ITYPE( XAnimationNodeSupplier ) ) 582 { 583 if( mbIsImpressDocument ) 584 { 585 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD; 586 587 if( ePageKind == PK_STANDARD ) 588 return makeAny( Reference< XAnimationNodeSupplier >( this ) ); 589 } 590 } 591 else 592 return SvxDrawPage::queryInterface( rType ); 593 594 return aAny; 595 } 596 597 // XPropertySet 598 Reference< beans::XPropertySetInfo > SAL_CALL SdGenericDrawPage::getPropertySetInfo() 599 { 600 OGuard aGuard( Application::GetSolarMutex() ); 601 throwIfDisposed(); 602 return mpPropSet->getPropertySetInfo(); 603 } 604 605 void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) 606 { 607 OGuard aGuard( Application::GetSolarMutex() ); 608 609 throwIfDisposed(); 610 611 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName); 612 613 switch( pEntry ? pEntry->nWID : -1 ) 614 { 615 case WID_NAVORDER: 616 setNavigationOrder( aValue ); 617 break; 618 case WID_PAGE_LEFT: 619 case WID_PAGE_RIGHT: 620 case WID_PAGE_TOP: 621 case WID_PAGE_BOTTOM: 622 case WID_PAGE_LAYOUT: 623 case WID_PAGE_DURATION: 624 case WID_PAGE_CHANGE: 625 { 626 sal_Int32 nValue = 0; 627 if(!(aValue >>= nValue)) 628 throw lang::IllegalArgumentException(); 629 630 switch( pEntry->nWID ) 631 { 632 case WID_PAGE_LEFT: 633 SetLftBorder(nValue); 634 break; 635 case WID_PAGE_RIGHT: 636 SetRgtBorder( nValue ); 637 break; 638 case WID_PAGE_TOP: 639 SetUppBorder( nValue ); 640 break; 641 case WID_PAGE_BOTTOM: 642 SetLwrBorder( nValue ); 643 break; 644 case WID_PAGE_CHANGE: 645 GetPage()->SetPresChange( (PresChange)nValue ); 646 break; 647 case WID_PAGE_LAYOUT: 648 GetPage()->SetAutoLayout( (AutoLayout)nValue, sal_True ); 649 break; 650 case WID_PAGE_DURATION: 651 GetPage()->SetTime((sal_uInt32)nValue); 652 break; 653 } 654 break; 655 } 656 case WID_PAGE_WIDTH: 657 { 658 sal_Int32 nWidth = 0; 659 if(!(aValue >>= nWidth)) 660 throw lang::IllegalArgumentException(); 661 662 SetWidth( nWidth ); 663 break; 664 } 665 case WID_PAGE_HEIGHT: 666 { 667 sal_Int32 nHeight = 0; 668 if(!(aValue >>= nHeight)) 669 throw lang::IllegalArgumentException(); 670 671 SetHeight( nHeight ); 672 break; 673 } 674 case WID_PAGE_ORIENT: 675 { 676 sal_Int32 nEnum = 0; 677 if(!::cppu::enum2int( nEnum, aValue )) 678 throw lang::IllegalArgumentException(); 679 680 Orientation eOri = (((view::PaperOrientation)nEnum) == view::PaperOrientation_PORTRAIT)?ORIENTATION_PORTRAIT:ORIENTATION_LANDSCAPE; 681 682 if( eOri != GetPage()->GetOrientation() ) 683 { 684 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel(); 685 const PageKind ePageKind = GetPage()->GetPageKind(); 686 687 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind); 688 for (i = 0; i < nPageCnt; i++) 689 { 690 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind); 691 pPage->SetOrientation( eOri ); 692 } 693 694 nPageCnt = pDoc->GetSdPageCount(ePageKind); 695 696 for (i = 0; i < nPageCnt; i++) 697 { 698 SdPage* pPage = pDoc->GetSdPage(i, ePageKind); 699 pPage->SetOrientation( eOri ); 700 } 701 } 702 break; 703 } 704 case WID_PAGE_EFFECT: 705 { 706 sal_Int32 nEnum = 0; 707 if(!::cppu::enum2int( nEnum, aValue )) 708 throw lang::IllegalArgumentException(); 709 710 GetPage()->SetFadeEffect( (presentation::FadeEffect)nEnum ); 711 break; 712 } 713 case WID_PAGE_BACK: 714 setBackground( aValue ); 715 break; 716 case WID_PAGE_SPEED: 717 { 718 sal_Int32 nEnum = 0; 719 if(!::cppu::enum2int( nEnum, aValue )) 720 throw lang::IllegalArgumentException(); 721 722 GetPage()->setTransitionDuration( nEnum == 0 ? 3.0 : (nEnum == 1 ? 2.0 : 1.0 ) ); 723 break; 724 } 725 case WID_PAGE_VISIBLE : 726 { 727 sal_Bool bVisible = sal_False; 728 if( ! ( aValue >>= bVisible ) ) 729 throw lang::IllegalArgumentException(); 730 GetPage()->SetExcluded( bVisible == sal_False ); 731 break; 732 } 733 case WID_PAGE_SOUNDFILE : 734 { 735 OUString aURL; 736 if( aValue >>= aURL ) 737 { 738 GetPage()->SetSoundFile( aURL ); 739 GetPage()->SetSound( aURL.getLength() != 0 ? sal_True : sal_False ); 740 break; 741 } 742 else 743 { 744 sal_Bool bStopSound = sal_False; 745 if( aValue >>= bStopSound ) 746 { 747 GetPage()->SetStopSound( bStopSound ? true : false ); 748 break; 749 } 750 } 751 752 753 throw lang::IllegalArgumentException(); 754 } 755 case WID_LOOP_SOUND: 756 { 757 sal_Bool bLoop = sal_False; 758 if( ! (aValue >>= bLoop) ) 759 throw lang::IllegalArgumentException(); 760 761 GetPage()->SetLoopSound( bLoop ? true : false ); 762 break; 763 } 764 case WID_PAGE_BACKFULL: 765 { 766 sal_Bool bFullSize = sal_False; 767 if( ! ( aValue >>= bFullSize ) ) 768 throw lang::IllegalArgumentException(); 769 GetPage()->SetBackgroundFullSize( bFullSize ); 770 break; 771 } 772 case WID_PAGE_BACKVIS: 773 { 774 sal_Bool bVisible = sal_False; 775 if( ! ( aValue >>= bVisible ) ) 776 throw lang::IllegalArgumentException(); 777 778 SdrPage* pPage = GetPage(); 779 if( pPage ) 780 { 781 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel(); 782 if( pDoc->GetMasterPageCount() ) 783 { 784 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin(); 785 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); 786 aVisibleLayers.Set(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False), bVisible); 787 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); 788 } 789 } 790 break; 791 } 792 case WID_PAGE_BACKOBJVIS: 793 { 794 sal_Bool bVisible = sal_False; 795 if( ! ( aValue >>= bVisible ) ) 796 throw lang::IllegalArgumentException(); 797 798 SdrPage* pPage = GetPage(); 799 if( pPage ) 800 { 801 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel(); 802 if( pDoc->GetMasterPageCount() ) 803 { 804 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin(); 805 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); 806 aVisibleLayers.Set(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False), bVisible); 807 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); 808 } 809 } 810 811 break; 812 } 813 case WID_PAGE_USERATTRIBS: 814 { 815 if( !GetPage()->setAlienAttributes( aValue ) ) 816 throw lang::IllegalArgumentException(); 817 break; 818 } 819 case WID_PAGE_BOOKMARK: 820 { 821 OUString aBookmarkURL; 822 if( ! ( aValue >>= aBookmarkURL ) ) 823 throw lang::IllegalArgumentException(); 824 825 setBookmarkURL( aBookmarkURL ); 826 break; 827 } 828 829 case WID_PAGE_HEADERVISIBLE: 830 case WID_PAGE_HEADERTEXT: 831 case WID_PAGE_FOOTERVISIBLE: 832 case WID_PAGE_FOOTERTEXT: 833 case WID_PAGE_PAGENUMBERVISIBLE: 834 case WID_PAGE_DATETIMEVISIBLE: 835 case WID_PAGE_DATETIMEFIXED: 836 case WID_PAGE_DATETIMETEXT: 837 case WID_PAGE_DATETIMEFORMAT: 838 { 839 sd::HeaderFooterSettings aHeaderFooterSettings( GetPage()->getHeaderFooterSettings() ); 840 841 switch( pEntry->nWID ) 842 { 843 case WID_PAGE_HEADERVISIBLE: 844 { 845 sal_Bool bVisible = sal_False; 846 if( ! ( aValue >>= bVisible ) ) 847 throw lang::IllegalArgumentException(); 848 849 aHeaderFooterSettings.mbHeaderVisible = bVisible; 850 break; 851 } 852 case WID_PAGE_HEADERTEXT: 853 { 854 OUString aText; 855 if( ! ( aValue >>= aText ) ) 856 throw lang::IllegalArgumentException(); 857 858 aHeaderFooterSettings.maHeaderText = aText; 859 break; 860 } 861 case WID_PAGE_FOOTERVISIBLE: 862 { 863 sal_Bool bVisible = sal_False; 864 if( ! ( aValue >>= bVisible ) ) 865 throw lang::IllegalArgumentException(); 866 867 aHeaderFooterSettings.mbFooterVisible = bVisible; 868 break; 869 } 870 case WID_PAGE_FOOTERTEXT: 871 { 872 OUString aText; 873 if( ! ( aValue >>= aText ) ) 874 throw lang::IllegalArgumentException(); 875 876 aHeaderFooterSettings.maFooterText = aText; 877 break; 878 } 879 case WID_PAGE_PAGENUMBERVISIBLE: 880 { 881 sal_Bool bVisible = sal_False; 882 if( ! ( aValue >>= bVisible ) ) 883 throw lang::IllegalArgumentException(); 884 885 aHeaderFooterSettings.mbSlideNumberVisible = bVisible; 886 break; 887 } 888 case WID_PAGE_DATETIMEVISIBLE: 889 { 890 sal_Bool bVisible = sal_False; 891 if( ! ( aValue >>= bVisible ) ) 892 throw lang::IllegalArgumentException(); 893 894 aHeaderFooterSettings.mbDateTimeVisible = bVisible; 895 break; 896 } 897 case WID_PAGE_DATETIMEFIXED: 898 { 899 sal_Bool bVisible = sal_False; 900 if( ! ( aValue >>= bVisible ) ) 901 throw lang::IllegalArgumentException(); 902 903 aHeaderFooterSettings.mbDateTimeIsFixed = bVisible; 904 break; 905 } 906 case WID_PAGE_DATETIMETEXT: 907 { 908 OUString aText; 909 if( ! ( aValue >>= aText ) ) 910 throw lang::IllegalArgumentException(); 911 912 aHeaderFooterSettings.maDateTimeText = aText; 913 break; 914 } 915 case WID_PAGE_DATETIMEFORMAT: 916 { 917 sal_Int32 nValue = 0; 918 if( ! ( aValue >>= nValue ) ) 919 throw lang::IllegalArgumentException(); 920 921 aHeaderFooterSettings.meDateTimeFormat = nValue; 922 break; 923 } 924 } 925 926 if( !(aHeaderFooterSettings == GetPage()->getHeaderFooterSettings()) ) 927 GetPage()->setHeaderFooterSettings( aHeaderFooterSettings ); 928 929 break; 930 } 931 932 case WID_PAGE_NUMBER: 933 if( (GetPage()->GetPageKind() == PK_HANDOUT) && !GetPage()->IsMasterPage() ) 934 { 935 if( !(aValue >>= mnTempPageNumber) ) 936 throw lang::IllegalArgumentException(); 937 938 break; 939 } 940 throw beans::PropertyVetoException(); 941 942 case WID_PAGE_LDBITMAP: 943 case WID_PAGE_LDNAME: 944 case WID_PAGE_ISDARK: 945 throw beans::PropertyVetoException(); 946 947 case WID_TRANSITION_TYPE: 948 { 949 sal_Int16 nValue = 0; 950 if( ! ( aValue >>= nValue ) ) 951 throw lang::IllegalArgumentException(); 952 953 GetPage()->setTransitionType( nValue ); 954 break; 955 } 956 957 case WID_TRANSITION_SUBTYPE: 958 { 959 sal_Int16 nValue = 0; 960 if( ! ( aValue >>= nValue ) ) 961 throw lang::IllegalArgumentException(); 962 963 GetPage()->setTransitionSubtype( nValue ); 964 break; 965 } 966 967 case WID_TRANSITION_DIRECTION: 968 { 969 sal_Bool bValue = sal_False; 970 if( ! ( aValue >>= bValue ) ) 971 throw lang::IllegalArgumentException(); 972 973 GetPage()->setTransitionDirection( bValue ); 974 break; 975 } 976 977 case WID_TRANSITION_FADE_COLOR: 978 { 979 sal_Int32 nValue = 0; 980 if( ! ( aValue >>= nValue ) ) 981 throw lang::IllegalArgumentException(); 982 983 GetPage()->setTransitionFadeColor( nValue ); 984 break; 985 } 986 987 case WID_TRANSITION_DURATION: 988 { 989 double fValue = 0.0; 990 if( ! ( aValue >>= fValue ) ) 991 throw lang::IllegalArgumentException(); 992 993 GetPage()->setTransitionDuration( fValue ); 994 break; 995 } 996 997 default: 998 throw beans::UnknownPropertyException(); 999 } 1000 1001 GetModel()->SetModified(); 1002 } 1003 1004 /*********************************************************************** 1005 * * 1006 ***********************************************************************/ 1007 Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName ) 1008 { 1009 OGuard aGuard( Application::GetSolarMutex() ); 1010 1011 throwIfDisposed(); 1012 1013 uno::Any aAny; 1014 1015 const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName); 1016 1017 switch( pEntry ? pEntry->nWID : -1 ) 1018 { 1019 case WID_NAVORDER: 1020 aAny = getNavigationOrder(); 1021 break; 1022 case WID_PAGE_LEFT: 1023 aAny <<= (sal_Int32)( GetPage()->GetLftBorder() ); 1024 break; 1025 case WID_PAGE_RIGHT: 1026 aAny <<= (sal_Int32)( GetPage()->GetRgtBorder() ); 1027 break; 1028 case WID_PAGE_TOP: 1029 aAny <<= (sal_Int32)( GetPage()->GetUppBorder() ); 1030 break; 1031 case WID_PAGE_BOTTOM: 1032 aAny <<= (sal_Int32)( GetPage()->GetLwrBorder() ); 1033 break; 1034 case WID_PAGE_WIDTH: 1035 aAny <<= (sal_Int32)( GetPage()->GetSize().getWidth() ); 1036 break; 1037 case WID_PAGE_HEIGHT: 1038 aAny <<= (sal_Int32)( GetPage()->GetSize().getHeight() ); 1039 break; 1040 case WID_PAGE_ORIENT: 1041 aAny = ::cppu::int2enum( (sal_Int32)((GetPage()->GetOrientation() == ORIENTATION_PORTRAIT)? view::PaperOrientation_PORTRAIT: view::PaperOrientation_LANDSCAPE), ::getCppuType((const view::PaperOrientation*)0) ); 1042 break; 1043 case WID_PAGE_EFFECT: 1044 aAny = ::cppu::int2enum( (sal_Int32)GetPage()->GetFadeEffect(), ::getCppuType((const presentation::FadeEffect*)0) ); 1045 break; 1046 case WID_PAGE_CHANGE: 1047 aAny <<= (sal_Int32)( GetPage()->GetPresChange() ); 1048 break; 1049 case WID_PAGE_SPEED: 1050 { 1051 const double fDuration = GetPage()->getTransitionDuration(); 1052 aAny = ::cppu::int2enum( fDuration < 2.0 ? 2 : (fDuration > 2.0 ? 0 : 1), ::getCppuType((const presentation::AnimationSpeed*)0) ); 1053 } 1054 break; 1055 case WID_PAGE_LAYOUT: 1056 aAny <<= (sal_Int16)( GetPage()->GetAutoLayout() ); 1057 break; 1058 case WID_PAGE_NUMBER: 1059 { 1060 const sal_uInt16 nPageNumber(GetPage()->GetPageNum()); 1061 1062 if(nPageNumber > 0) 1063 { 1064 // for all other pages calculate the number 1065 aAny <<= (sal_Int16)((sal_uInt16)((nPageNumber-1)>>1) + 1); 1066 } 1067 else 1068 { 1069 aAny <<= mnTempPageNumber; 1070 } 1071 } 1072 break; 1073 case WID_PAGE_DURATION: 1074 aAny <<= (sal_Int32)(GetPage()->GetTime()); 1075 break; 1076 case WID_PAGE_LDNAME: 1077 { 1078 const OUString aName( GetPage()->GetName() ); 1079 aAny <<= aName; 1080 break; 1081 } 1082 case WID_PAGE_LDBITMAP: 1083 { 1084 sal_Bool bHC = Application::GetSettings().GetStyleSettings().GetHighContrastMode(); 1085 Reference< awt::XBitmap > xBitmap( 1086 VCLUnoHelper::CreateBitmap( BitmapEx( SdResId( bHC ? BMP_PAGE_H : BMP_PAGE ) ) ) ); 1087 aAny <<= xBitmap; 1088 } 1089 break; 1090 case WID_PAGE_BACK: 1091 getBackground( aAny ); 1092 break; 1093 case WID_PAGE_PREVIEW : 1094 { 1095 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel(); 1096 if ( pDoc ) 1097 { 1098 ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh(); 1099 if ( pDocShell ) 1100 { 1101 sal_uInt16 nPgNum = 0; 1102 sal_uInt16 nPageCount = pDoc->GetSdPageCount( PK_STANDARD ); 1103 sal_uInt16 nPageNumber = (sal_uInt16)( ( GetPage()->GetPageNum() - 1 ) >> 1 ); 1104 while( nPgNum < nPageCount ) 1105 { 1106 pDoc->SetSelected( pDoc->GetSdPage( nPgNum, PK_STANDARD ), nPgNum == nPageNumber ); 1107 nPgNum++; 1108 } 1109 ::boost::shared_ptr<GDIMetaFile> pMetaFile = 1110 pDocShell->GetPreviewMetaFile(); 1111 if ( pMetaFile ) 1112 { 1113 Point aPoint; 1114 Size aSize( GetPage()->GetSize() ); 1115 pMetaFile->AddAction( (MetaAction*) new MetaFillColorAction( COL_WHITE, sal_True ), 0 ); 1116 pMetaFile->AddAction( (MetaAction*) new MetaRectAction( Rectangle( aPoint, aSize ) ), 1 ); 1117 pMetaFile->SetPrefMapMode( MAP_100TH_MM ); 1118 pMetaFile->SetPrefSize( aSize ); 1119 1120 SvMemoryStream aDestStrm( 65535, 65535 ); 1121 ConvertGDIMetaFileToWMF( *pMetaFile, aDestStrm, NULL, sal_False ); 1122 Sequence<sal_Int8> aSeq( (sal_Int8*)aDestStrm.GetData(), aDestStrm.Tell() ); 1123 aAny <<= aSeq; 1124 } 1125 } 1126 } 1127 } 1128 break; 1129 1130 case WID_PAGE_PREVIEWBITMAP : 1131 { 1132 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel(); 1133 if ( pDoc ) 1134 { 1135 ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh(); 1136 if ( pDocShell ) 1137 { 1138 sal_uInt16 nPgNum = 0; 1139 sal_uInt16 nPageCount = pDoc->GetSdPageCount( PK_STANDARD ); 1140 sal_uInt16 nPageNumber = (sal_uInt16)( ( GetPage()->GetPageNum() - 1 ) >> 1 ); 1141 while( nPgNum < nPageCount ) 1142 { 1143 pDoc->SetSelected( pDoc->GetSdPage( nPgNum, PK_STANDARD ), nPgNum == nPageNumber ); 1144 nPgNum++; 1145 } 1146 ::boost::shared_ptr<GDIMetaFile> pMetaFile = 1147 pDocShell->GetPreviewMetaFile(); 1148 BitmapEx aBitmap; 1149 if ( pMetaFile && pMetaFile->CreateThumbnail( 160, /* magic value taken from GraphicHelper::getThumbnailFormatFromGDI_Impl() */ 1150 aBitmap ) ) 1151 { 1152 SvMemoryStream aMemStream; 1153 WriteDIB(aBitmap.GetBitmap(), aMemStream, false, false); 1154 uno::Sequence<sal_Int8> aSeq( (sal_Int8*)aMemStream.GetData(), aMemStream.Tell() ); 1155 aAny <<= aSeq; 1156 } 1157 } 1158 } 1159 } 1160 break; 1161 1162 case WID_PAGE_VISIBLE : 1163 { 1164 sal_Bool bVisible = GetPage()->IsExcluded() == sal_False; 1165 aAny <<= Any( &bVisible, ::getBooleanCppuType() ); 1166 break; 1167 } 1168 1169 case WID_PAGE_SOUNDFILE : 1170 { 1171 if( GetPage()->IsStopSound() ) 1172 { 1173 aAny <<= sal_True; 1174 } 1175 else 1176 { 1177 OUString aURL; 1178 if( GetPage()->IsSoundOn() ) 1179 aURL = GetPage()->GetSoundFile(); 1180 aAny <<= aURL; 1181 } 1182 break; 1183 } 1184 case WID_LOOP_SOUND: 1185 { 1186 aAny <<= (sal_Bool)GetPage()->IsLoopSound(); 1187 break; 1188 } 1189 case WID_PAGE_BACKFULL: 1190 { 1191 sal_Bool bFullSize = GetPage()->IsBackgroundFullSize(); 1192 aAny = Any( &bFullSize, ::getBooleanCppuType() ); 1193 break; 1194 } 1195 case WID_PAGE_BACKVIS: 1196 { 1197 SdrPage* pPage = GetPage(); 1198 if( pPage ) 1199 { 1200 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel(); 1201 if( pDoc->GetMasterPageCount() ) 1202 { 1203 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin(); 1204 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); 1205 aAny <<= (sal_Bool)aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False)); 1206 } 1207 else 1208 { 1209 aAny <<= (sal_Bool)sal_False; 1210 } 1211 } 1212 break; 1213 } 1214 case WID_PAGE_BACKOBJVIS: 1215 { 1216 SdrPage* pPage = GetPage(); 1217 if( pPage ) 1218 { 1219 SdDrawDocument* pDoc = (SdDrawDocument*)pPage->GetModel(); 1220 if( pDoc->GetMasterPageCount() ) 1221 { 1222 SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin(); 1223 SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); 1224 aAny <<= (sal_Bool)aVisibleLayers.IsSet(rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False)); 1225 } 1226 else 1227 { 1228 aAny <<= (sal_Bool)sal_False; 1229 } 1230 } 1231 break; 1232 } 1233 case WID_PAGE_USERATTRIBS: 1234 { 1235 GetPage()->getAlienAttributes( aAny ); 1236 break; 1237 } 1238 case WID_PAGE_BOOKMARK: 1239 { 1240 aAny <<= getBookmarkURL(); 1241 break; 1242 } 1243 case WID_PAGE_ISDARK: 1244 { 1245 aAny <<= (sal_Bool)GetPage()->GetPageBackgroundColor().IsDark(); 1246 break; 1247 } 1248 case WID_PAGE_HEADERVISIBLE: 1249 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbHeaderVisible; 1250 break; 1251 case WID_PAGE_HEADERTEXT: 1252 { 1253 const OUString aText( GetPage()->getHeaderFooterSettings().maHeaderText ); 1254 aAny <<= aText; 1255 } 1256 break; 1257 case WID_PAGE_FOOTERVISIBLE: 1258 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbFooterVisible; 1259 break; 1260 case WID_PAGE_FOOTERTEXT: 1261 { 1262 const OUString aText( GetPage()->getHeaderFooterSettings().maFooterText ); 1263 aAny <<= aText; 1264 } 1265 break; 1266 case WID_PAGE_PAGENUMBERVISIBLE: 1267 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbSlideNumberVisible; 1268 break; 1269 case WID_PAGE_DATETIMEVISIBLE: 1270 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbDateTimeVisible; 1271 break; 1272 case WID_PAGE_DATETIMEFIXED: 1273 aAny <<= (sal_Bool)GetPage()->getHeaderFooterSettings().mbDateTimeIsFixed; 1274 break; 1275 case WID_PAGE_DATETIMETEXT: 1276 { 1277 const OUString aText( GetPage()->getHeaderFooterSettings().maDateTimeText ); 1278 aAny <<= aText; 1279 } 1280 break; 1281 case WID_PAGE_DATETIMEFORMAT: 1282 aAny <<= (sal_Int32)GetPage()->getHeaderFooterSettings().meDateTimeFormat; 1283 break; 1284 1285 case WID_TRANSITION_TYPE: 1286 aAny <<= GetPage()->getTransitionType(); 1287 break; 1288 1289 case WID_TRANSITION_SUBTYPE: 1290 aAny <<= GetPage()->getTransitionSubtype(); 1291 break; 1292 1293 case WID_TRANSITION_DIRECTION: 1294 aAny <<= GetPage()->getTransitionDirection(); 1295 break; 1296 1297 case WID_TRANSITION_FADE_COLOR: 1298 aAny <<= GetPage()->getTransitionFadeColor(); 1299 break; 1300 1301 case WID_TRANSITION_DURATION: 1302 aAny <<= GetPage()->getTransitionDuration(); 1303 break; 1304 1305 default: 1306 throw beans::UnknownPropertyException(); 1307 } 1308 return aAny; 1309 } 1310 1311 void SAL_CALL SdGenericDrawPage::addPropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& ) {} 1312 void SAL_CALL SdGenericDrawPage::removePropertyChangeListener( const OUString& , const Reference< beans::XPropertyChangeListener >& ) {} 1313 void SAL_CALL SdGenericDrawPage::addVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) {} 1314 void SAL_CALL SdGenericDrawPage::removeVetoableChangeListener( const OUString& , const Reference< beans::XVetoableChangeListener >& ) {} 1315 1316 // XMultiPropertySet 1317 void SAL_CALL SdGenericDrawPage::setPropertyValues( const Sequence< OUString >& aPropertyNames, const Sequence< Any >& aValues ) 1318 { 1319 if( aPropertyNames.getLength() != aValues.getLength() ) 1320 throw lang::IllegalArgumentException(); 1321 1322 const OUString* pNames = aPropertyNames.getConstArray(); 1323 const Any* pValues = aValues.getConstArray(); 1324 sal_uInt32 nCount = aValues.getLength(); 1325 while( nCount-- ) 1326 { 1327 try 1328 { 1329 setPropertyValue( *pNames++, *pValues++ ); 1330 } 1331 catch( beans::UnknownPropertyException& ) 1332 { 1333 // ignore for multi property set 1334 // todo: optimize this! 1335 } 1336 } 1337 } 1338 1339 Sequence< Any > SAL_CALL SdGenericDrawPage::getPropertyValues( const Sequence< OUString >& aPropertyNames ) 1340 { 1341 const OUString* pNames = aPropertyNames.getConstArray(); 1342 sal_uInt32 nCount = aPropertyNames.getLength(); 1343 Sequence< Any > aValues( nCount ); 1344 Any* pValues = aValues.getArray(); 1345 while( nCount-- ) 1346 { 1347 Any aValue; 1348 try 1349 { 1350 aValue = getPropertyValue( *pNames++ ); 1351 } 1352 catch( beans::UnknownPropertyException& ) 1353 { 1354 // ignore for multi property set 1355 // todo: optimize this! 1356 } 1357 *pValues++ = aValue; 1358 } 1359 return aValues; 1360 } 1361 1362 void SAL_CALL SdGenericDrawPage::addPropertiesChangeListener( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >& ) 1363 { 1364 } 1365 1366 void SAL_CALL SdGenericDrawPage::removePropertiesChangeListener( const Reference< beans::XPropertiesChangeListener >& ) 1367 { 1368 } 1369 1370 void SAL_CALL SdGenericDrawPage::firePropertiesChangeEvent( const Sequence< OUString >& , const Reference< beans::XPropertiesChangeListener >& ) 1371 { 1372 } 1373 1374 Reference< drawing::XShape > SdGenericDrawPage::_CreateShape( SdrObject *pObj ) const throw() 1375 { 1376 DBG_ASSERT( GetPage(), "SdGenericDrawPage::_CreateShape(), can't create shape for disposed page!" ); 1377 DBG_ASSERT( pObj, "SdGenericDrawPage::_CreateShape(), invalid call with pObj == 0!" ); 1378 1379 if( GetPage() && pObj ) 1380 { 1381 PresObjKind eKind = GetPage()->GetPresObjKind(pObj); 1382 1383 SvxShape* pShape = NULL; 1384 1385 if(pObj->GetObjInventor() == SdrInventor) 1386 { 1387 sal_uInt32 nInventor = pObj->GetObjIdentifier(); 1388 switch( nInventor ) 1389 { 1390 case OBJ_TITLETEXT: 1391 pShape = new SvxShapeText( pObj ); 1392 if( GetPage()->GetPageKind() == PK_NOTES && GetPage()->IsMasterPage() ) 1393 { 1394 // fake a empty PageShape if its a title shape on the master page 1395 pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape"))); 1396 } 1397 else 1398 { 1399 pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape"))); 1400 } 1401 eKind = PRESOBJ_NONE; 1402 break; 1403 case OBJ_OUTLINETEXT: 1404 pShape = new SvxShapeText( pObj ); 1405 pShape->SetShapeType(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape"))); 1406 eKind = PRESOBJ_NONE; 1407 break; 1408 } 1409 } 1410 1411 Reference< drawing::XShape > xShape( pShape ); 1412 1413 if(!xShape.is()) 1414 xShape = SvxFmDrawPage::_CreateShape( pObj ); 1415 1416 1417 if( eKind != PRESOBJ_NONE ) 1418 { 1419 String aShapeType( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.")); 1420 1421 switch( eKind ) 1422 { 1423 case PRESOBJ_TITLE: 1424 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("TitleTextShape") ); 1425 break; 1426 case PRESOBJ_OUTLINE: 1427 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OutlinerShape") ); 1428 break; 1429 case PRESOBJ_TEXT: 1430 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("SubtitleShape") ); 1431 break; 1432 case PRESOBJ_GRAPHIC: 1433 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("GraphicObjectShape") ); 1434 break; 1435 case PRESOBJ_OBJECT: 1436 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OLE2Shape") ); 1437 break; 1438 case PRESOBJ_CHART: 1439 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("ChartShape") ); 1440 break; 1441 case PRESOBJ_ORGCHART: 1442 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("OrgChartShape") ); 1443 break; 1444 case PRESOBJ_CALC: 1445 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("CalcShape") ); 1446 break; 1447 case PRESOBJ_TABLE: 1448 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("TableShape") ); 1449 break; 1450 case PRESOBJ_MEDIA: 1451 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("MediaShape") ); 1452 break; 1453 case PRESOBJ_PAGE: 1454 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("PageShape") ); 1455 break; 1456 case PRESOBJ_HANDOUT: 1457 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("HandoutShape") ); 1458 break; 1459 case PRESOBJ_NOTES: 1460 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("NotesShape") ); 1461 break; 1462 case PRESOBJ_FOOTER: 1463 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("FooterShape") ); 1464 break; 1465 case PRESOBJ_HEADER: 1466 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("HeaderShape") ); 1467 break; 1468 case PRESOBJ_SLIDENUMBER: 1469 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("SlideNumberShape") ); 1470 break; 1471 case PRESOBJ_DATETIME: 1472 aShapeType += String( RTL_CONSTASCII_USTRINGPARAM("DateTimeShape") ); 1473 break; 1474 case PRESOBJ_NONE: 1475 case PRESOBJ_IMAGE: 1476 case PRESOBJ_MAX: 1477 break; 1478 } 1479 1480 if( !pShape ) 1481 pShape = SvxShape::getImplementation( xShape ); 1482 1483 if( pShape ) 1484 pShape->SetShapeType( aShapeType ); 1485 } 1486 1487 // SdXShape aggregiert SvxShape 1488 new SdXShape( SvxShape::getImplementation( xShape ), GetModel() ); 1489 return xShape; 1490 } 1491 else 1492 { 1493 return SvxFmDrawPage::_CreateShape( pObj ); 1494 } 1495 1496 } 1497 1498 //---------------------------------------------------------------------- 1499 1500 // XServiceInfo 1501 Sequence< OUString > SAL_CALL SdGenericDrawPage::getSupportedServiceNames() 1502 { 1503 Sequence< OUString > aSeq( SvxFmDrawPage::getSupportedServiceNames() ); 1504 comphelper::ServiceInfoHelper::addToSequence( aSeq, 3, "com.sun.star.drawing.GenericDrawPage", 1505 "com.sun.star.document.LinkTarget", 1506 "com.sun.star.document.LinkTargetSupplier"); 1507 return aSeq; 1508 } 1509 1510 //---------------------------------------------------------------------- 1511 1512 // XLinkTargetSupplier 1513 Reference< container::XNameAccess > SAL_CALL SdGenericDrawPage::getLinks( ) 1514 { 1515 return new SdPageLinkTargets( (SdGenericDrawPage*)this ); 1516 } 1517 1518 //---------------------------------------------------------------------- 1519 1520 void SdGenericDrawPage::setBackground( const Any& ) 1521 { 1522 DBG_ERROR( "Don't call me, I'm useless!" ); 1523 } 1524 1525 //---------------------------------------------------------------------- 1526 1527 void SdGenericDrawPage::getBackground( Any& ) throw() 1528 { 1529 DBG_ERROR( "Don't call me, I'm useless!" ); 1530 } 1531 1532 //---------------------------------------------------------------------- 1533 1534 OUString SdGenericDrawPage::getBookmarkURL() const 1535 { 1536 OUStringBuffer aRet; 1537 if( SvxFmDrawPage::mpPage ) 1538 { 1539 OUString aFileName( static_cast<SdPage*>(SvxFmDrawPage::mpPage)->GetFileName() ); 1540 if( aFileName.getLength() ) 1541 { 1542 const OUString aBookmarkName( SdDrawPage::getPageApiNameFromUiName( static_cast<SdPage*>(SvxFmDrawPage::mpPage)->GetBookmarkName() ) ); 1543 aRet.append( aFileName ); 1544 aRet.append( (sal_Unicode)'#' ); 1545 aRet.append( aBookmarkName ); 1546 } 1547 } 1548 1549 return aRet.makeStringAndClear(); 1550 } 1551 1552 //---------------------------------------------------------------------- 1553 void SdGenericDrawPage::setBookmarkURL( rtl::OUString& rURL ) 1554 { 1555 if( SvxFmDrawPage::mpPage ) 1556 { 1557 sal_Int32 nIndex = rURL.indexOf( (sal_Unicode)'#' ); 1558 if( nIndex != -1 ) 1559 { 1560 const String aFileName( rURL.copy( 0, nIndex ) ); 1561 const String aBookmarkName( SdDrawPage::getUiNameFromPageApiName( rURL.copy( nIndex+1 ) ) ); 1562 1563 if( aFileName.Len() && aBookmarkName.Len() ) 1564 { 1565 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->DisconnectLink(); 1566 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->SetFileName( aFileName ); 1567 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->SetBookmarkName( aBookmarkName ); 1568 static_cast<SdPage*>(SvxFmDrawPage::mpPage)->ConnectLink(); 1569 } 1570 } 1571 } 1572 } 1573 1574 //---------------------------------------------------------------------- 1575 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::combine( const Reference< drawing::XShapes >& xShapes ) 1576 { 1577 OGuard aGuard( Application::GetSolarMutex() ); 1578 1579 throwIfDisposed(); 1580 1581 DBG_ASSERT(SvxFmDrawPage::mpPage,"SdrPage ist NULL! [CL]"); 1582 DBG_ASSERT(mpView, "SdrView ist NULL! [CL]"); 1583 1584 Reference< drawing::XShape > xShape; 1585 if(mpView==NULL||!xShapes.is()||GetPage()==NULL) 1586 return xShape; 1587 1588 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() ); 1589 1590 _SelectObjectsInView( xShapes, pPageView ); 1591 1592 mpView->CombineMarkedObjects( sal_False ); 1593 1594 mpView->AdjustMarkHdl(); 1595 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); 1596 if( rMarkList.GetMarkCount() == 1 ) 1597 { 1598 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 1599 if( pObj ) 1600 xShape = Reference< drawing::XShape >::query( pObj->getUnoShape() ); 1601 } 1602 1603 mpView->HideSdrPage(); 1604 1605 GetModel()->SetModified(); 1606 1607 return xShape; 1608 } 1609 1610 //---------------------------------------------------------------------- 1611 void SAL_CALL SdGenericDrawPage::split( const Reference< drawing::XShape >& xGroup ) 1612 { 1613 OGuard aGuard( Application::GetSolarMutex() ); 1614 1615 throwIfDisposed(); 1616 1617 if(mpView==NULL||!xGroup.is()||GetPage()==NULL) 1618 return; 1619 1620 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() ); 1621 _SelectObjectInView( xGroup, pPageView ); 1622 mpView->DismantleMarkedObjects( sal_False ); 1623 mpView->HideSdrPage(); 1624 1625 GetModel()->SetModified(); 1626 } 1627 1628 //---------------------------------------------------------------------- 1629 Reference< drawing::XShape > SAL_CALL SdGenericDrawPage::bind( const Reference< drawing::XShapes >& xShapes ) 1630 { 1631 OGuard aGuard( Application::GetSolarMutex() ); 1632 1633 throwIfDisposed(); 1634 1635 uno::Reference< drawing::XShape > xShape; 1636 if(mpView==NULL||!xShapes.is()||GetPage()==NULL) 1637 return xShape; 1638 1639 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() ); 1640 1641 _SelectObjectsInView( xShapes, pPageView ); 1642 1643 mpView->CombineMarkedObjects( sal_True ); 1644 1645 mpView->AdjustMarkHdl(); 1646 const SdrMarkList& rMarkList = mpView->GetMarkedObjectList(); 1647 if( rMarkList.GetMarkCount() == 1 ) 1648 { 1649 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 1650 if( pObj ) 1651 xShape = Reference< drawing::XShape >::query( pObj->getUnoShape() ); 1652 } 1653 1654 mpView->HideSdrPage(); 1655 1656 GetModel()->SetModified(); 1657 1658 return xShape; 1659 } 1660 1661 //---------------------------------------------------------------------- 1662 void SAL_CALL SdGenericDrawPage::unbind( const Reference< drawing::XShape >& xShape ) 1663 { 1664 OGuard aGuard( Application::GetSolarMutex() ); 1665 1666 throwIfDisposed(); 1667 1668 if(mpView==NULL||!xShape.is()||GetPage()==NULL) 1669 return; 1670 1671 SdrPageView* pPageView = mpView->ShowSdrPage( GetPage() ); 1672 _SelectObjectInView( xShape, pPageView ); 1673 mpView->DismantleMarkedObjects( sal_True ); 1674 mpView->HideSdrPage(); 1675 1676 GetModel()->SetModified(); 1677 } 1678 1679 void SdGenericDrawPage::SetLftBorder( sal_Int32 nValue ) 1680 { 1681 if( nValue != GetPage()->GetLftBorder() ) 1682 { 1683 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel(); 1684 const PageKind ePageKind = GetPage()->GetPageKind(); 1685 1686 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind); 1687 for (i = 0; i < nPageCnt; i++) 1688 { 1689 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind); 1690 pPage->SetLftBorder( nValue ); 1691 } 1692 1693 nPageCnt = pDoc->GetSdPageCount(ePageKind); 1694 1695 for (i = 0; i < nPageCnt; i++) 1696 { 1697 SdPage* pPage = pDoc->GetSdPage(i, ePageKind); 1698 pPage->SetLftBorder( nValue ); 1699 } 1700 } 1701 } 1702 1703 void SdGenericDrawPage::SetRgtBorder( sal_Int32 nValue ) 1704 { 1705 if( nValue != GetPage()->GetRgtBorder() ) 1706 { 1707 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel(); 1708 const PageKind ePageKind = GetPage()->GetPageKind(); 1709 1710 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind); 1711 for (i = 0; i < nPageCnt; i++) 1712 { 1713 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind); 1714 pPage->SetRgtBorder( nValue ); 1715 } 1716 1717 nPageCnt = pDoc->GetSdPageCount(ePageKind); 1718 1719 for (i = 0; i < nPageCnt; i++) 1720 { 1721 SdPage* pPage = pDoc->GetSdPage(i, ePageKind); 1722 pPage->SetRgtBorder( nValue ); 1723 } 1724 } 1725 } 1726 1727 void SdGenericDrawPage::SetUppBorder( sal_Int32 nValue ) 1728 { 1729 if( nValue != GetPage()->GetUppBorder() ) 1730 { 1731 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel(); 1732 const PageKind ePageKind = GetPage()->GetPageKind(); 1733 1734 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind); 1735 for (i = 0; i < nPageCnt; i++) 1736 { 1737 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind); 1738 pPage->SetUppBorder( nValue ); 1739 } 1740 1741 nPageCnt = pDoc->GetSdPageCount(ePageKind); 1742 1743 for (i = 0; i < nPageCnt; i++) 1744 { 1745 SdPage* pPage = pDoc->GetSdPage(i, ePageKind); 1746 pPage->SetUppBorder( nValue ); 1747 } 1748 } 1749 } 1750 1751 void SdGenericDrawPage::SetLwrBorder( sal_Int32 nValue ) 1752 { 1753 if( nValue != GetPage()->GetLwrBorder() ) 1754 { 1755 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel(); 1756 const PageKind ePageKind = GetPage()->GetPageKind(); 1757 1758 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind); 1759 for (i = 0; i < nPageCnt; i++) 1760 { 1761 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind); 1762 pPage->SetLwrBorder( nValue ); 1763 } 1764 1765 nPageCnt = pDoc->GetSdPageCount(ePageKind); 1766 1767 for (i = 0; i < nPageCnt; i++) 1768 { 1769 SdPage* pPage = pDoc->GetSdPage(i, ePageKind); 1770 pPage->SetLwrBorder( nValue ); 1771 } 1772 } 1773 } 1774 1775 static void refreshpage( SdDrawDocument* pDoc, const PageKind ePageKind ) 1776 { 1777 ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh(); 1778 if ( pDocShell ) 1779 { 1780 ::sd::ViewShell* pViewSh = pDocShell->GetViewShell(); 1781 1782 if( pViewSh ) 1783 { 1784 if( pViewSh->ISA(::sd::DrawViewShell ) ) 1785 static_cast< ::sd::DrawViewShell*>(pViewSh)->ResetActualPage(); 1786 1787 Size aPageSize = pDoc->GetSdPage(0, ePageKind)->GetSize(); 1788 const long nWidth = aPageSize.Width(); 1789 const long nHeight = aPageSize.Height(); 1790 1791 Point aPageOrg = Point(nWidth, nHeight / 2); 1792 Size aViewSize = Size(nWidth * 3, nHeight * 2); 1793 1794 pDoc->SetMaxObjSize(aViewSize); 1795 1796 pViewSh->InitWindows(aPageOrg, aViewSize, Point(-1, -1), sal_True); 1797 1798 pViewSh->UpdateScrollBars(); 1799 } 1800 } 1801 } 1802 1803 void SdGenericDrawPage::SetWidth( sal_Int32 nWidth ) 1804 { 1805 Size aSize( GetPage()->GetSize() ); 1806 if( aSize.getWidth() != nWidth ) 1807 { 1808 aSize.setWidth( nWidth ); 1809 1810 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel(); 1811 const PageKind ePageKind = GetPage()->GetPageKind(); 1812 1813 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind); 1814 for (i = 0; i < nPageCnt; i++) 1815 { 1816 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind); 1817 pPage->SetSize(aSize); 1818 } 1819 1820 nPageCnt = pDoc->GetSdPageCount(ePageKind); 1821 1822 for (i = 0; i < nPageCnt; i++) 1823 { 1824 SdPage* pPage = pDoc->GetSdPage(i, ePageKind); 1825 pPage->SetSize(aSize); 1826 } 1827 1828 refreshpage( pDoc, ePageKind ); 1829 } 1830 } 1831 1832 void SdGenericDrawPage::SetHeight( sal_Int32 nHeight ) 1833 { 1834 Size aSize( GetPage()->GetSize() ); 1835 if( aSize.getHeight() != nHeight ) 1836 { 1837 aSize.setHeight( nHeight ); 1838 1839 SdDrawDocument* pDoc = (SdDrawDocument*)GetPage()->GetModel(); 1840 const PageKind ePageKind = GetPage()->GetPageKind(); 1841 1842 sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind); 1843 for (i = 0; i < nPageCnt; i++) 1844 { 1845 SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind); 1846 pPage->SetSize(aSize); 1847 } 1848 1849 nPageCnt = pDoc->GetSdPageCount(ePageKind); 1850 1851 for (i = 0; i < nPageCnt; i++) 1852 { 1853 SdPage* pPage = pDoc->GetSdPage(i, ePageKind); 1854 pPage->SetSize(aSize); 1855 } 1856 1857 refreshpage( pDoc, ePageKind ); 1858 } 1859 } 1860 1861 // XInterface 1862 void SdGenericDrawPage::release() throw() 1863 { 1864 1865 OWeakAggObject::release(); 1866 } 1867 1868 // XComponent 1869 void SdGenericDrawPage::disposing() throw() 1870 { 1871 mpModel = 0; 1872 SvxFmDrawPage::disposing(); 1873 } 1874 1875 // XAnimationNodeSupplier 1876 Reference< XAnimationNode > SAL_CALL SdGenericDrawPage::getAnimationNode() 1877 { 1878 OGuard aGuard( Application::GetSolarMutex() ); 1879 1880 throwIfDisposed(); 1881 1882 SdPage *pSdPage = static_cast<SdPage*>(SvxFmDrawPage::mpPage); 1883 1884 1885 return pSdPage->getAnimationNode(); 1886 } 1887 1888 //======================================================================== 1889 // SdPageLinkTargets 1890 //======================================================================== 1891 1892 SdPageLinkTargets::SdPageLinkTargets( SdGenericDrawPage* pUnoPage ) throw() 1893 { 1894 mxPage = pUnoPage; 1895 mpUnoPage = pUnoPage; 1896 } 1897 1898 SdPageLinkTargets::~SdPageLinkTargets() throw() 1899 { 1900 } 1901 1902 // XElementAccess 1903 uno::Type SAL_CALL SdPageLinkTargets::getElementType() 1904 { 1905 return ITYPE(beans::XPropertySet); 1906 } 1907 1908 sal_Bool SAL_CALL SdPageLinkTargets::hasElements() 1909 { 1910 OGuard aGuard( Application::GetSolarMutex() ); 1911 1912 SdPage* pPage = mpUnoPage->GetPage(); 1913 if( pPage != NULL ) 1914 { 1915 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); 1916 1917 while( aIter.IsMore() ) 1918 { 1919 SdrObject* pObj = aIter.Next(); 1920 String aStr( pObj->GetName() ); 1921 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) ) 1922 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName(); 1923 if( aStr.Len() ) 1924 return sal_True; 1925 } 1926 } 1927 1928 return sal_False; 1929 } 1930 1931 // container::XNameAccess 1932 1933 // XNameAccess 1934 Any SAL_CALL SdPageLinkTargets::getByName( const OUString& aName ) 1935 { 1936 OGuard aGuard( Application::GetSolarMutex() ); 1937 1938 SdPage* pPage = mpUnoPage->GetPage(); 1939 if( pPage != NULL ) 1940 { 1941 SdrObject* pObj = FindObject( aName ); 1942 if( pObj ) 1943 { 1944 Reference< beans::XPropertySet > aRef( pObj->getUnoShape(), uno::UNO_QUERY ); 1945 return makeAny( aRef ); 1946 } 1947 } 1948 1949 throw container::NoSuchElementException(); 1950 } 1951 1952 Sequence< OUString > SAL_CALL SdPageLinkTargets::getElementNames() 1953 { 1954 OGuard aGuard( Application::GetSolarMutex() ); 1955 1956 sal_uInt32 nObjCount = 0; 1957 1958 SdPage* pPage = mpUnoPage->GetPage(); 1959 if( pPage != NULL ) 1960 { 1961 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); 1962 while( aIter.IsMore() ) 1963 { 1964 SdrObject* pObj = aIter.Next(); 1965 String aStr( pObj->GetName() ); 1966 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) ) 1967 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName(); 1968 if( aStr.Len() ) 1969 nObjCount++; 1970 } 1971 } 1972 1973 Sequence< OUString > aSeq( nObjCount ); 1974 if( nObjCount > 0 ) 1975 { 1976 OUString* pStr = aSeq.getArray(); 1977 1978 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); 1979 while( aIter.IsMore() ) 1980 { 1981 SdrObject* pObj = aIter.Next(); 1982 String aStr( pObj->GetName() ); 1983 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) ) 1984 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName(); 1985 if( aStr.Len() ) 1986 *pStr++ = aStr; 1987 } 1988 } 1989 1990 return aSeq; 1991 } 1992 1993 sal_Bool SAL_CALL SdPageLinkTargets::hasByName( const OUString& aName ) 1994 { 1995 OGuard aGuard( Application::GetSolarMutex() ); 1996 1997 return FindObject( aName ) != NULL; 1998 } 1999 2000 /*********************************************************************** 2001 * * 2002 ***********************************************************************/ 2003 SdrObject* SdPageLinkTargets::FindObject( const String& rName ) const throw() 2004 { 2005 SdPage* pPage = mpUnoPage->GetPage(); 2006 if( pPage == NULL ) 2007 return NULL; 2008 2009 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); 2010 2011 while( aIter.IsMore() ) 2012 { 2013 SdrObject* pObj = aIter.Next(); 2014 String aStr( pObj->GetName() ); 2015 if( !aStr.Len() && pObj->ISA( SdrOle2Obj ) ) 2016 aStr = static_cast< const SdrOle2Obj* >( pObj )->GetPersistName(); 2017 if( aStr.Len() && (aStr == rName) ) 2018 return pObj; 2019 } 2020 2021 return NULL; 2022 } 2023 2024 // XServiceInfo 2025 OUString SAL_CALL SdPageLinkTargets::getImplementationName() 2026 { 2027 return OUString( RTL_CONSTASCII_USTRINGPARAM("SdPageLinkTargets") ); 2028 } 2029 2030 sal_Bool SAL_CALL SdPageLinkTargets::supportsService( const OUString& ServiceName ) 2031 { 2032 return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); 2033 } 2034 2035 Sequence< OUString > SAL_CALL SdPageLinkTargets::getSupportedServiceNames() 2036 { 2037 const OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.LinkTargets") ); 2038 Sequence< OUString > aSeq( &aSN, 1); 2039 return aSeq; 2040 } 2041 2042 //======================================================================== 2043 // SdDrawPage 2044 //======================================================================== 2045 2046 SdDrawPage::SdDrawPage( SdXImpressDocument* pModel, SdPage* pPage ) throw() 2047 : SdGenericDrawPage( pModel, pPage, ImplGetDrawPagePropertySet( pModel->IsImpressDocument(), pPage->GetPageKind() ) ) 2048 { 2049 } 2050 2051 SdDrawPage::~SdDrawPage() throw() 2052 { 2053 } 2054 2055 // XInterface 2056 Any SAL_CALL SdDrawPage::queryInterface( const uno::Type & rType ) 2057 { 2058 if( rType == ITYPE( drawing::XMasterPageTarget ) ) 2059 { 2060 return makeAny( Reference< drawing::XMasterPageTarget >( this ) ); 2061 } 2062 else 2063 { 2064 if( mbIsImpressDocument ) 2065 { 2066 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD; 2067 2068 if( ePageKind != PK_HANDOUT && rType == ITYPE( presentation::XPresentationPage ) ) 2069 { 2070 return makeAny( Reference< presentation::XPresentationPage >( this ) ); 2071 } 2072 } 2073 } 2074 2075 return SdGenericDrawPage::queryInterface( rType ); 2076 } 2077 2078 void SAL_CALL SdDrawPage::acquire() throw() 2079 { 2080 SvxDrawPage::acquire(); 2081 } 2082 2083 void SAL_CALL SdDrawPage::release() throw() 2084 { 2085 SvxDrawPage::release(); 2086 } 2087 2088 UNO3_GETIMPLEMENTATION2_IMPL( SdDrawPage, SdGenericDrawPage ); 2089 2090 // XTypeProvider 2091 Sequence< uno::Type > SAL_CALL SdDrawPage::getTypes() 2092 { 2093 OGuard aGuard( Application::GetSolarMutex() ); 2094 2095 throwIfDisposed(); 2096 2097 if( maTypeSequence.getLength() == 0 ) 2098 { 2099 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD; 2100 sal_Bool bPresPage = mbIsImpressDocument && ePageKind != PK_HANDOUT; 2101 2102 // Collect the types of this class. 2103 ::std::vector<uno::Type> aTypes; 2104 aTypes.reserve(13); 2105 aTypes.push_back(ITYPE(drawing::XDrawPage)); 2106 aTypes.push_back(ITYPE(beans::XPropertySet)); 2107 aTypes.push_back(ITYPE(container::XNamed)); 2108 aTypes.push_back(ITYPE(drawing::XMasterPageTarget)); 2109 aTypes.push_back(ITYPE(lang::XServiceInfo)); 2110 aTypes.push_back(ITYPE(util::XReplaceable)); 2111 aTypes.push_back(ITYPE(document::XLinkTargetSupplier)); 2112 aTypes.push_back(ITYPE( drawing::XShapeCombiner )); 2113 aTypes.push_back(ITYPE( drawing::XShapeBinder )); 2114 aTypes.push_back(ITYPE( office::XAnnotationAccess )); 2115 aTypes.push_back(ITYPE( beans::XMultiPropertySet )); 2116 if( bPresPage ) 2117 aTypes.push_back(ITYPE(presentation::XPresentationPage)); 2118 if( bPresPage && ePageKind == PK_STANDARD ) 2119 aTypes.push_back(ITYPE(XAnimationNodeSupplier)); 2120 2121 // Get types of base class. 2122 const Sequence< uno::Type > aBaseTypes( SdGenericDrawPage::getTypes() ); 2123 const sal_Int32 nBaseTypes = aBaseTypes.getLength(); 2124 const uno::Type* pBaseTypes = aBaseTypes.getConstArray(); 2125 2126 // Join those types in a sequence. 2127 maTypeSequence.realloc(aTypes.size() + nBaseTypes); 2128 uno::Type* pTypes = maTypeSequence.getArray(); 2129 ::std::vector<uno::Type>::const_iterator iType; 2130 for (iType=aTypes.begin(); iType!=aTypes.end(); ++iType) 2131 *pTypes++ = *iType; 2132 for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ ) 2133 *pTypes++ = *pBaseTypes++; 2134 } 2135 2136 return maTypeSequence; 2137 } 2138 2139 Sequence< sal_Int8 > SAL_CALL SdDrawPage::getImplementationId() 2140 { 2141 OGuard aGuard( Application::GetSolarMutex() ); 2142 2143 throwIfDisposed(); 2144 2145 static Sequence< sal_Int8 > aId; 2146 if( aId.getLength() == 0 ) 2147 { 2148 aId.realloc( 16 ); 2149 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); 2150 } 2151 return aId; 2152 } 2153 2154 OUString SdDrawPage::getPageApiName( SdPage* pPage ) 2155 { 2156 return ::getPageApiName( pPage ); 2157 } 2158 2159 OUString getPageApiName( SdPage* pPage ) 2160 { 2161 OUString aPageName; 2162 2163 if(pPage) 2164 { 2165 aPageName = pPage->GetRealName(); 2166 2167 if( aPageName.getLength() == 0 ) 2168 { 2169 OUStringBuffer sBuffer; 2170 sBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( sEmptyPageName ) ); 2171 const sal_Int32 nPageNum = ( ( pPage->GetPageNum() - 1 ) >> 1 ) + 1; 2172 sBuffer.append( nPageNum ); 2173 aPageName = sBuffer.makeStringAndClear(); 2174 } 2175 } 2176 2177 return aPageName; 2178 } 2179 2180 2181 OUString getPageApiNameFromUiName( const String& rUIName ) 2182 { 2183 OUString aApiName; 2184 2185 String aDefPageName(SdResId(STR_PAGE)); 2186 aDefPageName += sal_Unicode( ' ' ); 2187 2188 if( rUIName.Equals( aDefPageName, 0, aDefPageName.Len() ) ) 2189 { 2190 aApiName = OUString( RTL_CONSTASCII_USTRINGPARAM( sEmptyPageName ) ); 2191 aApiName += rUIName.Copy( aDefPageName.Len() ); 2192 } 2193 else 2194 { 2195 aApiName = rUIName; 2196 } 2197 2198 return aApiName; 2199 } 2200 2201 OUString SdDrawPage::getPageApiNameFromUiName( const String& rUIName ) 2202 { 2203 return ::getPageApiNameFromUiName( rUIName ); 2204 } 2205 2206 String getUiNameFromPageApiNameImpl( const OUString& rApiName ) 2207 { 2208 const String aDefPageName(RTL_CONSTASCII_USTRINGPARAM( sEmptyPageName )); 2209 if( rApiName.compareTo( aDefPageName, aDefPageName.Len() ) == 0 ) 2210 { 2211 OUString aNumber( rApiName.copy( sizeof( sEmptyPageName ) - 1 ) ); 2212 2213 // create the page number 2214 sal_Int32 nPageNumber = aNumber.toInt32(); 2215 2216 // check if there are non number characters in the number part 2217 const sal_Int32 nChars = aNumber.getLength(); 2218 const sal_Unicode* pString = aNumber.getStr(); 2219 sal_Int32 nChar; 2220 for( nChar = 0; nChar < nChars; nChar++, pString++ ) 2221 { 2222 if((*pString < sal_Unicode('0')) || (*pString > sal_Unicode('9'))) 2223 { 2224 // found a non number character, so this is not the default 2225 // name for this page 2226 nPageNumber = -1; 2227 break; 2228 } 2229 } 2230 2231 if( nPageNumber != -1) 2232 { 2233 OUStringBuffer sBuffer; 2234 sBuffer.append( String(SdResId(STR_PAGE)) ); 2235 sBuffer.append( sal_Unicode( ' ' ) ); 2236 sBuffer.append( aNumber ); 2237 return sBuffer.makeStringAndClear(); 2238 } 2239 } 2240 2241 return rApiName; 2242 } 2243 2244 String SdDrawPage::getUiNameFromPageApiName( const OUString& rApiName ) 2245 { 2246 return getUiNameFromPageApiNameImpl( rApiName ); 2247 } 2248 2249 // XServiceInfo 2250 OUString SAL_CALL SdDrawPage::getImplementationName() 2251 { 2252 return OUString( RTL_CONSTASCII_USTRINGPARAM("SdDrawPage") ); 2253 } 2254 2255 Sequence< OUString > SAL_CALL SdDrawPage::getSupportedServiceNames() 2256 { 2257 OGuard aGuard( Application::GetSolarMutex() ); 2258 2259 throwIfDisposed(); 2260 2261 Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() ); 2262 comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.DrawPage" ); 2263 2264 if( mbIsImpressDocument ) 2265 comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.DrawPage" ); 2266 2267 return aSeq; 2268 } 2269 2270 sal_Bool SAL_CALL SdDrawPage::supportsService( const OUString& ServiceName ) 2271 { 2272 return SdGenericDrawPage::supportsService( ServiceName ); 2273 } 2274 2275 // XNamed 2276 void SAL_CALL SdDrawPage::setName( const OUString& rName ) 2277 { 2278 OGuard aGuard( Application::GetSolarMutex() ); 2279 2280 throwIfDisposed(); 2281 2282 DBG_ASSERT( GetPage() && !GetPage()->IsMasterPage(), "Don't call base implementation for masterpages!" ); 2283 2284 OUString aName( rName ); 2285 2286 if(GetPage() && GetPage()->GetPageKind() != PK_NOTES) 2287 { 2288 // check if this is the default 'page1234' name 2289 if(aName.compareToAscii( sEmptyPageName, sizeof( sEmptyPageName ) - 1 ) == 0) 2290 { 2291 // ok, it maybe is, first get the number part after 'page' 2292 OUString aNumber( aName.copy( sizeof( sEmptyPageName ) - 1 ) ); 2293 2294 // create the page number 2295 sal_Int32 nPageNumber = aNumber.toInt32(); 2296 2297 // check if there are non number characters in the number part 2298 const sal_Int32 nChars = aNumber.getLength(); 2299 const sal_Unicode* pString = aNumber.getStr(); 2300 sal_Int32 nChar; 2301 for( nChar = 0; nChar < nChars; nChar++, pString++ ) 2302 { 2303 if((*pString < '0') || (*pString > '9')) 2304 { 2305 // found a non number character, so this is not the default 2306 // name for this page 2307 nPageNumber = -1; 2308 break; 2309 } 2310 } 2311 2312 if( nPageNumber == ( ( GetPage()->GetPageNum() - 1 ) >> 1 ) + 1 ) 2313 aName = OUString(); 2314 } 2315 else 2316 { 2317 String aDefaultPageName( SdResId(STR_PAGE) ); 2318 aDefaultPageName += sal_Unicode( ' ' ); 2319 if( aName.compareTo( aDefaultPageName, aDefaultPageName.Len() ) == 0 ) 2320 aName = OUString(); 2321 } 2322 2323 GetPage()->SetName( aName ); 2324 2325 sal_uInt16 nNotesPageNum = (GetPage()->GetPageNum()-1)>>1; 2326 if( GetModel()->GetDoc()->GetSdPageCount( PK_NOTES ) > nNotesPageNum ) 2327 { 2328 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( nNotesPageNum, PK_NOTES ); 2329 if( pNotesPage ) 2330 pNotesPage->SetName(aName); 2331 } 2332 2333 // fake a mode change to repaint the page tab bar 2334 ::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell(); 2335 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL; 2336 if( pViewSh && pViewSh->ISA(::sd::DrawViewShell)) 2337 { 2338 ::sd::DrawViewShell* pDrawViewSh = static_cast< 2339 ::sd::DrawViewShell*>(pViewSh); 2340 2341 EditMode eMode = pDrawViewSh->GetEditMode(); 2342 if( eMode == EM_PAGE ) 2343 { 2344 sal_Bool bLayer = pDrawViewSh->IsLayerModeActive(); 2345 2346 pDrawViewSh->ChangeEditMode( eMode, !bLayer ); 2347 pDrawViewSh->ChangeEditMode( eMode, bLayer ); 2348 } 2349 } 2350 2351 GetModel()->SetModified(); 2352 } 2353 } 2354 2355 OUString SAL_CALL SdDrawPage::getName() 2356 { 2357 OGuard aGuard( Application::GetSolarMutex() ); 2358 2359 throwIfDisposed(); 2360 2361 return getPageApiName( GetPage() ); 2362 } 2363 2364 // XMasterPageTarget 2365 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getMasterPage( ) 2366 { 2367 OGuard aGuard( Application::GetSolarMutex() ); 2368 2369 throwIfDisposed(); 2370 2371 if(GetPage()) 2372 { 2373 Reference< drawing::XDrawPages > xPages( GetModel()->getMasterPages() ); 2374 Reference< drawing::XDrawPage > xPage; 2375 2376 if(SvxFmDrawPage::mpPage->TRG_HasMasterPage()) 2377 { 2378 SdrPage& rMasterPage = SvxFmDrawPage::mpPage->TRG_GetMasterPage(); 2379 xPage = uno::Reference< drawing::XDrawPage >( rMasterPage.getUnoPage(), uno::UNO_QUERY ); 2380 } 2381 2382 return xPage; 2383 } 2384 return NULL; 2385 } 2386 2387 void SAL_CALL SdDrawPage::setMasterPage( const Reference< drawing::XDrawPage >& xMasterPage ) 2388 { 2389 OGuard aGuard( Application::GetSolarMutex() ); 2390 2391 throwIfDisposed(); 2392 2393 if(SvxFmDrawPage::mpPage) 2394 { 2395 SdMasterPage* pMasterPage = SdMasterPage::getImplementation( xMasterPage ); 2396 if( pMasterPage && pMasterPage->isValid() ) 2397 { 2398 SvxFmDrawPage::mpPage->TRG_ClearMasterPage(); 2399 2400 SdPage* pSdPage = (SdPage*) pMasterPage->GetSdrPage(); 2401 SvxFmDrawPage::mpPage->TRG_SetMasterPage(*pSdPage); 2402 2403 SvxFmDrawPage::mpPage->SetBorder(pSdPage->GetLftBorder(),pSdPage->GetUppBorder(), 2404 pSdPage->GetRgtBorder(),pSdPage->GetLwrBorder() ); 2405 2406 SvxFmDrawPage::mpPage->SetSize( pSdPage->GetSize() ); 2407 SvxFmDrawPage::mpPage->SetOrientation( pSdPage->GetOrientation() ); 2408 ((SdPage*)SvxFmDrawPage::mpPage)->SetLayoutName( ( (SdPage*)pSdPage )->GetLayoutName() ); 2409 2410 // set notes master also 2411 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES ); 2412 2413 pNotesPage->TRG_ClearMasterPage(); 2414 sal_uInt16 nNum = (SvxFmDrawPage::mpPage->TRG_GetMasterPage()).GetPageNum() + 1; 2415 pNotesPage->TRG_SetMasterPage(*SvxFmDrawPage::mpPage->GetModel()->GetMasterPage(nNum)); 2416 pNotesPage->SetLayoutName( ( (SdPage*)pSdPage )->GetLayoutName() ); 2417 2418 GetModel()->SetModified(); 2419 } 2420 2421 } 2422 } 2423 2424 // XPresentationPage 2425 Reference< drawing::XDrawPage > SAL_CALL SdDrawPage::getNotesPage() 2426 { 2427 OGuard aGuard( Application::GetSolarMutex() ); 2428 2429 throwIfDisposed(); 2430 2431 if(SvxFmDrawPage::mpPage && GetModel()->GetDoc() && SvxFmDrawPage::mpPage->GetPageNum() ) 2432 { 2433 SdPage* pNotesPage = GetModel()->GetDoc()->GetSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES ); 2434 if( pNotesPage ) 2435 { 2436 Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY ); 2437 return xPage; 2438 } 2439 } 2440 return NULL; 2441 } 2442 2443 2444 // XIndexAccess 2445 sal_Int32 SAL_CALL SdDrawPage::getCount() 2446 { 2447 return SdGenericDrawPage::getCount(); 2448 } 2449 2450 Any SAL_CALL SdDrawPage::getByIndex( sal_Int32 Index ) 2451 { 2452 return SdGenericDrawPage::getByIndex( Index ); 2453 } 2454 2455 // XElementAccess 2456 uno::Type SAL_CALL SdDrawPage::getElementType() 2457 { 2458 return SdGenericDrawPage::getElementType(); 2459 } 2460 2461 sal_Bool SAL_CALL SdDrawPage::hasElements() 2462 { 2463 return SdGenericDrawPage::hasElements(); 2464 } 2465 2466 // XShapes 2467 void SAL_CALL SdDrawPage::add( const Reference< drawing::XShape >& xShape ) 2468 { 2469 SdGenericDrawPage::add( xShape ); 2470 } 2471 2472 void SAL_CALL SdDrawPage::remove( const Reference< drawing::XShape >& xShape ) 2473 { 2474 OGuard aGuard( Application::GetSolarMutex() ); 2475 2476 throwIfDisposed(); 2477 2478 SvxShape* pShape = SvxShape::getImplementation( xShape ); 2479 if( pShape ) 2480 { 2481 SdrObject* pObj = pShape->GetSdrObject(); 2482 if( pObj ) 2483 { 2484 GetPage()->RemovePresObj(pObj); 2485 pObj->SetUserCall(NULL); 2486 } 2487 } 2488 2489 SdGenericDrawPage::remove( xShape ); 2490 } 2491 2492 void SdDrawPage::setBackground( const Any& rValue ) 2493 { 2494 Reference< beans::XPropertySet > xSet; 2495 2496 if( !(rValue >>= xSet) && !rValue.hasValue() ) 2497 throw lang::IllegalArgumentException(); 2498 2499 if( !xSet.is() ) 2500 { 2501 // the easy case, no background set. Set XFILL_NONE to represent this 2502 GetPage()->getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE)); 2503 return; 2504 } 2505 2506 // is it our own implementation? 2507 SdUnoPageBackground* pBack = SdUnoPageBackground::getImplementation( xSet ); 2508 2509 SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST ); 2510 2511 if( pBack ) 2512 { 2513 pBack->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet ); 2514 } 2515 else 2516 { 2517 SdUnoPageBackground* pBackground = new SdUnoPageBackground(); 2518 2519 Reference< beans::XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() ); 2520 Reference< beans::XPropertySet > xDestSet( (beans::XPropertySet*)pBackground ); 2521 Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo() ); 2522 2523 Sequence< beans::Property > aProperties( xDestSetInfo->getProperties() ); 2524 sal_Int32 nCount = aProperties.getLength(); 2525 beans::Property* pProp = aProperties.getArray(); 2526 2527 while( nCount-- ) 2528 { 2529 const OUString aPropName( pProp->Name ); 2530 if( xSetInfo->hasPropertyByName( aPropName ) ) 2531 xDestSet->setPropertyValue( aPropName, 2532 xSet->getPropertyValue( aPropName ) ); 2533 2534 pProp++; 2535 } 2536 2537 pBackground->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet ); 2538 } 2539 2540 //-/ pObj->NbcSetAttributes( aSet, sal_False ); 2541 if( aSet.Count() == 0 ) 2542 { 2543 // no background fill, represent by setting XFILL_NONE 2544 GetPage()->getSdrPageProperties().PutItem(XFillStyleItem(XFILL_NONE)); 2545 } 2546 else 2547 { 2548 // background fill, set at page (not sure if ClearItem is needed) 2549 GetPage()->getSdrPageProperties().ClearItem(); 2550 GetPage()->getSdrPageProperties().PutItemSet(aSet); 2551 } 2552 2553 // repaint only 2554 SvxFmDrawPage::mpPage->ActionChanged(); 2555 // pPage->SendRepaintBroadcast(); 2556 } 2557 2558 // XAnnotationAccess: 2559 Reference< XAnnotation > SAL_CALL SdGenericDrawPage::createAndInsertAnnotation() 2560 { 2561 if( !GetPage() ) 2562 throw DisposedException(); 2563 2564 Reference< XAnnotation > xRet; 2565 GetPage()->createAnnotation(xRet); 2566 return xRet; 2567 } 2568 2569 void SAL_CALL SdGenericDrawPage::removeAnnotation(const Reference< XAnnotation > & annotation) 2570 { 2571 GetPage()->removeAnnotation(annotation); 2572 } 2573 2574 Reference< XAnnotationEnumeration > SAL_CALL SdGenericDrawPage::createAnnotationEnumeration() 2575 { 2576 return ::sd::createAnnotationEnumeration( GetPage()->getAnnotations() ); 2577 } 2578 2579 void SdDrawPage::getBackground( Any& rValue ) throw() 2580 { 2581 const SfxItemSet& rFillAttributes = GetPage()->getSdrPageProperties().GetItemSet(); 2582 2583 if(XFILL_NONE == ((const XFillStyleItem&)rFillAttributes.Get(XATTR_FILLSTYLE)).GetValue()) 2584 { 2585 // no fill set (switched off by XFILL_NONE), clear rValue to represent this 2586 rValue.clear(); 2587 } 2588 else 2589 { 2590 // there is a fill set, export to rValue 2591 Reference< beans::XPropertySet > xSet(new SdUnoPageBackground( 2592 GetModel()->GetDoc(), 2593 &GetPage()->getSdrPageProperties().GetItemSet())); 2594 rValue <<= xSet; 2595 } 2596 } 2597 2598 void SdGenericDrawPage::setNavigationOrder( const Any& rValue ) 2599 { 2600 Reference< XIndexAccess > xIA( rValue, UNO_QUERY ); 2601 if( xIA.is() ) 2602 { 2603 if( dynamic_cast< SdDrawPage* >( xIA.get() ) == this ) 2604 { 2605 if( GetPage()->HasObjectNavigationOrder() ) 2606 GetPage()->ClearObjectNavigationOrder(); 2607 2608 return; 2609 } 2610 else if( xIA->getCount() == static_cast< sal_Int32 >( GetPage()->GetObjCount() ) ) 2611 { 2612 GetPage()->SetNavigationOrder(xIA); 2613 return; 2614 } 2615 } 2616 throw IllegalArgumentException(); 2617 } 2618 2619 class NavigationOrderAccess : public ::cppu::WeakImplHelper1< XIndexAccess > 2620 { 2621 public: 2622 NavigationOrderAccess( SdrPage* pPage ); 2623 2624 // XIndexAccess 2625 virtual sal_Int32 SAL_CALL getCount( ); 2626 virtual Any SAL_CALL getByIndex( sal_Int32 Index ); 2627 2628 // XElementAccess 2629 virtual Type SAL_CALL getElementType( ); 2630 virtual sal_Bool SAL_CALL hasElements( ); 2631 2632 private: 2633 std::vector< Reference< XShape > > maShapes; 2634 }; 2635 2636 NavigationOrderAccess::NavigationOrderAccess( SdrPage* pPage ) 2637 : maShapes( static_cast< sal_uInt32 >( pPage ? pPage->GetObjCount() : 0 ) ) 2638 { 2639 if( pPage ) 2640 { 2641 sal_uInt32 nIndex; 2642 const sal_uInt32 nCount = static_cast< sal_uInt32 >( pPage->GetObjCount() ); 2643 for( nIndex = 0; nIndex < nCount; ++nIndex ) 2644 { 2645 SdrObject* pObj = pPage->GetObj( nIndex ); 2646 sal_uInt32 nNavPos = pObj->GetNavigationPosition(); 2647 DBG_ASSERT( !maShapes[nNavPos].is(), "sd::NavigationOrderAccess::NavigationOrderAccess(), duplicate navigation positions from core!" ); 2648 maShapes[nNavPos] = Reference< XShape >( pObj->getUnoShape(), UNO_QUERY ); 2649 } 2650 } 2651 } 2652 2653 // XIndexAccess 2654 sal_Int32 SAL_CALL NavigationOrderAccess::getCount( ) 2655 { 2656 return static_cast< sal_Int32 >( maShapes.size() ); 2657 } 2658 2659 Any SAL_CALL NavigationOrderAccess::getByIndex( sal_Int32 Index ) 2660 { 2661 if( (Index < 0) || (Index > getCount()) ) 2662 throw IndexOutOfBoundsException(); 2663 2664 return Any( maShapes[Index] ); 2665 } 2666 2667 // XElementAccess 2668 Type SAL_CALL NavigationOrderAccess::getElementType( ) 2669 { 2670 return XShape::static_type(); 2671 } 2672 2673 sal_Bool SAL_CALL NavigationOrderAccess::hasElements( ) 2674 { 2675 return maShapes.empty() ? sal_False : sal_True; 2676 } 2677 2678 Any SdGenericDrawPage::getNavigationOrder() 2679 { 2680 if( GetPage()->HasObjectNavigationOrder() ) 2681 { 2682 return Any( Reference< XIndexAccess >( new NavigationOrderAccess( GetPage() ) ) ); 2683 } 2684 else 2685 { 2686 return Any( Reference< XIndexAccess >( this ) ); 2687 } 2688 } 2689 2690 //======================================================================== 2691 // class SdMasterPage 2692 //======================================================================== 2693 2694 SdMasterPage::SdMasterPage( SdXImpressDocument* pModel, SdPage* pPage ) throw() 2695 : SdGenericDrawPage( pModel, pPage, ImplGetMasterPagePropertySet( pPage ? pPage->GetPageKind() : PK_STANDARD ) ) 2696 { 2697 } 2698 2699 SdMasterPage::~SdMasterPage() throw() 2700 { 2701 } 2702 2703 // XInterface 2704 Any SAL_CALL SdMasterPage::queryInterface( const uno::Type & rType ) 2705 { 2706 OGuard aGuard( Application::GetSolarMutex() ); 2707 2708 throwIfDisposed(); 2709 2710 uno::Any aAny; 2711 2712 if( rType == ITYPE( container::XIndexAccess ) ) 2713 aAny <<= Reference< container::XIndexAccess >((presentation::XPresentationPage*)(this)); 2714 else if( rType == ITYPE( container::XElementAccess ) ) 2715 aAny <<= Reference< container::XElementAccess >((presentation::XPresentationPage*)(this)); 2716 else if( rType == ITYPE( container::XNamed ) ) 2717 aAny <<= Reference< container::XNamed >(this); 2718 else if( rType == ITYPE( presentation::XPresentationPage ) && 2719 ( mbIsImpressDocument && 2720 GetPage() && GetPage()->GetPageKind() != PK_HANDOUT) ) 2721 aAny <<= Reference< presentation::XPresentationPage >( this ); 2722 else 2723 return SdGenericDrawPage::queryInterface( rType ); 2724 2725 return aAny; 2726 } 2727 2728 void SAL_CALL SdMasterPage::acquire() throw() 2729 { 2730 SvxDrawPage::acquire(); 2731 } 2732 2733 void SAL_CALL SdMasterPage::release() throw() 2734 { 2735 SvxDrawPage::release(); 2736 } 2737 2738 UNO3_GETIMPLEMENTATION2_IMPL( SdMasterPage, SdGenericDrawPage ); 2739 2740 // XTypeProvider 2741 Sequence< uno::Type > SAL_CALL SdMasterPage::getTypes() 2742 { 2743 OGuard aGuard( Application::GetSolarMutex() ); 2744 2745 throwIfDisposed(); 2746 2747 if( maTypeSequence.getLength() == 0 ) 2748 { 2749 const PageKind ePageKind = GetPage() ? GetPage()->GetPageKind() : PK_STANDARD; 2750 sal_Bool bPresPage = mbIsImpressDocument && SvxFmDrawPage::mpPage && ePageKind != PK_HANDOUT; 2751 2752 // Collect the types of this class. 2753 ::std::vector<uno::Type> aTypes; 2754 aTypes.reserve(12); 2755 aTypes.push_back(ITYPE(drawing::XDrawPage)); 2756 aTypes.push_back(ITYPE(beans::XPropertySet)); 2757 aTypes.push_back(ITYPE(container::XNamed)); 2758 aTypes.push_back(ITYPE(lang::XServiceInfo)); 2759 aTypes.push_back(ITYPE(util::XReplaceable)); 2760 aTypes.push_back(ITYPE(document::XLinkTargetSupplier)); 2761 aTypes.push_back(ITYPE( drawing::XShapeCombiner )); 2762 aTypes.push_back(ITYPE( drawing::XShapeBinder )); 2763 aTypes.push_back(ITYPE( office::XAnnotationAccess )); 2764 aTypes.push_back(ITYPE( beans::XMultiPropertySet )); 2765 if( bPresPage ) 2766 aTypes.push_back(ITYPE(presentation::XPresentationPage)); 2767 if( bPresPage && ePageKind == PK_STANDARD ) 2768 aTypes.push_back(ITYPE(XAnimationNodeSupplier)); 2769 2770 // Get types of base class. 2771 const Sequence< uno::Type > aBaseTypes( SdGenericDrawPage::getTypes() ); 2772 const sal_Int32 nBaseTypes = aBaseTypes.getLength(); 2773 const uno::Type* pBaseTypes = aBaseTypes.getConstArray(); 2774 2775 // Join those types in a sequence. 2776 maTypeSequence.realloc(aTypes.size() + nBaseTypes); 2777 uno::Type* pTypes = maTypeSequence.getArray(); 2778 ::std::vector<uno::Type>::const_iterator iType; 2779 for (iType=aTypes.begin(); iType!=aTypes.end(); ++iType) 2780 *pTypes++ = *iType; 2781 for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ ) 2782 *pTypes++ = *pBaseTypes++; 2783 } 2784 2785 return maTypeSequence; 2786 } 2787 2788 Sequence< sal_Int8 > SAL_CALL SdMasterPage::getImplementationId() 2789 { 2790 OGuard aGuard( Application::GetSolarMutex() ); 2791 2792 throwIfDisposed(); 2793 2794 static Sequence< sal_Int8 > aId; 2795 if( aId.getLength() == 0 ) 2796 { 2797 aId.realloc( 16 ); 2798 rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); 2799 } 2800 return aId; 2801 } 2802 2803 // XServiceInfo 2804 OUString SAL_CALL SdMasterPage::getImplementationName() 2805 { 2806 return OUString( RTL_CONSTASCII_USTRINGPARAM("SdMasterPage") ); 2807 } 2808 2809 Sequence< OUString > SAL_CALL SdMasterPage::getSupportedServiceNames() 2810 { 2811 OGuard aGuard( Application::GetSolarMutex() ); 2812 2813 throwIfDisposed(); 2814 2815 Sequence< OUString > aSeq( SdGenericDrawPage::getSupportedServiceNames() ); 2816 comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.drawing.MasterPage" ); 2817 2818 if( SvxFmDrawPage::mpPage && ((SdPage*)SvxFmDrawPage::mpPage)->GetPageKind() == PK_HANDOUT ) 2819 comphelper::ServiceInfoHelper::addToSequence( aSeq, 1, "com.sun.star.presentation.HandoutMasterPage" ); 2820 2821 return aSeq; 2822 } 2823 2824 sal_Bool SAL_CALL SdMasterPage::supportsService( const OUString& ServiceName ) 2825 { 2826 return SdGenericDrawPage::supportsService( ServiceName ); 2827 } 2828 2829 // XElementAccess 2830 sal_Bool SAL_CALL SdMasterPage::hasElements() 2831 { 2832 OGuard aGuard( Application::GetSolarMutex() ); 2833 2834 throwIfDisposed(); 2835 2836 if( SvxFmDrawPage::mpPage == NULL ) 2837 return sal_False; 2838 2839 return SvxFmDrawPage::mpPage->GetObjCount() > 0; 2840 } 2841 2842 uno::Type SAL_CALL SdMasterPage::getElementType() 2843 { 2844 return SdGenericDrawPage::getElementType(); 2845 } 2846 2847 // XIndexAccess 2848 sal_Int32 SAL_CALL SdMasterPage::getCount() 2849 { 2850 OGuard aGuard( Application::GetSolarMutex() ); 2851 2852 throwIfDisposed(); 2853 2854 return SdGenericDrawPage::getCount(); 2855 } 2856 2857 Any SAL_CALL SdMasterPage::getByIndex( sal_Int32 Index ) 2858 { 2859 OGuard aGuard( Application::GetSolarMutex() ); 2860 2861 throwIfDisposed(); 2862 2863 return SdGenericDrawPage::getByIndex(Index); 2864 } 2865 2866 // intern 2867 void SdMasterPage::setBackground( const Any& rValue ) 2868 { 2869 // we need at least an beans::XPropertySet 2870 Reference< beans::XPropertySet > xInputSet( rValue, UNO_QUERY ); 2871 if( !xInputSet.is() ) 2872 throw lang::IllegalArgumentException(); 2873 2874 try 2875 { 2876 if( GetModel() && mbIsImpressDocument ) 2877 { 2878 Reference< container::XNameAccess > xFamilies( GetModel()->getStyleFamilies(), UNO_QUERY_THROW ); 2879 Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW ) ; 2880 if( xFamily.is() ) 2881 { 2882 OUString aStyleName( OUString::createFromAscii(sUNO_PseudoSheet_Background) ); 2883 2884 Reference< beans::XPropertySet > xStyleSet( xFamily->getByName( aStyleName ), UNO_QUERY_THROW ); 2885 2886 Reference< beans::XPropertySetInfo > xSetInfo( xInputSet->getPropertySetInfo(), UNO_QUERY_THROW ); 2887 Reference< beans::XPropertyState > xSetStates( xInputSet, UNO_QUERY ); 2888 2889 PropertyEntryVector_t aBackgroundProperties = ImplGetPageBackgroundPropertySet()->getPropertyMap()->getPropertyEntries(); 2890 PropertyEntryVector_t::const_iterator aIt = aBackgroundProperties.begin(); 2891 while( aIt != aBackgroundProperties.end() ) 2892 { 2893 if( xSetInfo->hasPropertyByName( aIt->sName ) ) 2894 { 2895 if( !xSetStates.is() || xSetStates->getPropertyState( aIt->sName ) == beans::PropertyState_DIRECT_VALUE ) 2896 xStyleSet->setPropertyValue( aIt->sName, xInputSet->getPropertyValue( aIt->sName ) ); 2897 else 2898 xSetStates->setPropertyToDefault( aIt->sName ); 2899 } 2900 2901 ++aIt; 2902 } 2903 } 2904 } 2905 else 2906 { 2907 // first fill an item set 2908 // is it our own implementation? 2909 SdUnoPageBackground* pBack = SdUnoPageBackground::getImplementation( xInputSet ); 2910 2911 SfxItemSet aSet( GetModel()->GetDoc()->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST ); 2912 2913 if( pBack ) 2914 { 2915 pBack->fillItemSet( (SdDrawDocument*)GetPage()->GetModel(), aSet ); 2916 } 2917 else 2918 { 2919 SdUnoPageBackground* pBackground = new SdUnoPageBackground(); 2920 2921 Reference< beans::XPropertySetInfo > xInputSetInfo( xInputSet->getPropertySetInfo(), UNO_QUERY_THROW ); 2922 Reference< beans::XPropertySet > xDestSet( (beans::XPropertySet*)pBackground ); 2923 Reference< beans::XPropertySetInfo > xDestSetInfo( xDestSet->getPropertySetInfo(), UNO_QUERY_THROW ); 2924 2925 uno::Sequence< beans::Property> aProperties( xDestSetInfo->getProperties() ); 2926 sal_Int32 nCount = aProperties.getLength(); 2927 beans::Property* pProp = aProperties.getArray(); 2928 2929 while( nCount-- ) 2930 { 2931 const OUString aPropName( pProp->Name ); 2932 if( xInputSetInfo->hasPropertyByName( aPropName ) ) 2933 xDestSet->setPropertyValue( aPropName, xInputSet->getPropertyValue( aPropName ) ); 2934 2935 pProp++; 2936 } 2937 2938 pBackground->fillItemSet( (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel(), aSet ); 2939 } 2940 2941 // if we find the background style, copy the set to the background 2942 SdDrawDocument* pDoc = (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel(); 2943 SfxStyleSheetBasePool* pSSPool = (SfxStyleSheetBasePool*)pDoc->GetStyleSheetPool(); 2944 if(pSSPool) 2945 { 2946 String aLayoutName( static_cast< SdPage* >( SvxFmDrawPage::mpPage )->GetLayoutName() ); 2947 aLayoutName.Erase(aLayoutName.Search(String(RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR)))+4); 2948 aLayoutName += String(SdResId(STR_LAYOUT_BACKGROUND)); 2949 SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SD_STYLE_FAMILY_MASTERPAGE ); 2950 2951 if( pStyleSheet ) 2952 { 2953 pStyleSheet->GetItemSet().Put( aSet ); 2954 2955 // repaint only 2956 SvxFmDrawPage::mpPage->ActionChanged(); 2957 return; 2958 } 2959 } 2960 2961 // if no background style is available, set at page directly. This 2962 // is an error and should NOT happen (and will be asserted from the SdrPage) 2963 GetPage()->getSdrPageProperties().PutItemSet(aSet); 2964 } 2965 } 2966 catch( Exception& ) 2967 { 2968 DBG_ERROR("sd::SdMasterPage::setBackground(), exception caught!"); 2969 } 2970 } 2971 2972 void SdMasterPage::getBackground( Any& rValue ) throw() 2973 { 2974 if( GetModel() ) try 2975 { 2976 if( mbIsImpressDocument ) 2977 { 2978 Reference< container::XNameAccess > xFamilies( GetModel()->getStyleFamilies(), UNO_QUERY_THROW ); 2979 Reference< container::XNameAccess > xFamily( xFamilies->getByName( getName() ), UNO_QUERY_THROW ); 2980 2981 const OUString aStyleName( OUString::createFromAscii(sUNO_PseudoSheet_Background) ); 2982 rValue <<= Reference< beans::XPropertySet >( xFamily->getByName( aStyleName ), UNO_QUERY_THROW ); 2983 } 2984 else 2985 { 2986 SdDrawDocument* pDoc = (SdDrawDocument*)SvxFmDrawPage::mpPage->GetModel(); 2987 SfxStyleSheetBasePool* pSSPool = (SfxStyleSheetBasePool*)pDoc->GetStyleSheetPool(); 2988 if(pSSPool) 2989 { 2990 String aLayoutName( static_cast< SdPage* >(SvxFmDrawPage::mpPage)->GetLayoutName() ); 2991 aLayoutName.Erase( aLayoutName.Search(String(RTL_CONSTASCII_USTRINGPARAM(SD_LT_SEPARATOR)))+4); 2992 aLayoutName += String(SdResId(STR_LAYOUT_BACKGROUND)); 2993 SfxStyleSheetBase* pStyleSheet = pSSPool->Find( aLayoutName, SD_STYLE_FAMILY_MASTERPAGE ); 2994 2995 if( pStyleSheet ) 2996 { 2997 SfxItemSet aStyleSet( pStyleSheet->GetItemSet()); 2998 if( aStyleSet.Count() ) 2999 { 3000 rValue <<= Reference< beans::XPropertySet >( new SdUnoPageBackground( pDoc, &aStyleSet ) ); 3001 return; 3002 } 3003 } 3004 } 3005 3006 // No style found, use fill attributes from page background. This 3007 // should NOT happen and is an error 3008 const SfxItemSet& rFallbackItemSet(SvxFmDrawPage::mpPage->getSdrPageProperties().GetItemSet()); 3009 3010 if(XFILL_NONE == ((const XFillStyleItem&)rFallbackItemSet.Get(XATTR_FILLSTYLE)).GetValue()) 3011 { 3012 rValue <<= Reference< beans::XPropertySet >( 3013 new SdUnoPageBackground(GetModel()->GetDoc(), &rFallbackItemSet)); 3014 } 3015 else 3016 { 3017 rValue.clear(); 3018 } 3019 } 3020 } 3021 catch( Exception& ) 3022 { 3023 rValue.clear(); 3024 DBG_ERROR("sd::SdMasterPage::getBackground(), exception caught!"); 3025 } 3026 } 3027 3028 // XNamed 3029 void SAL_CALL SdMasterPage::setName( const OUString& aName ) 3030 { 3031 OGuard aGuard( Application::GetSolarMutex() ); 3032 3033 throwIfDisposed(); 3034 3035 if(SvxFmDrawPage::mpPage && GetPage()->GetPageKind() != PK_NOTES) 3036 { 3037 String aNewName( aName ); 3038 GetPage()->SetName( aNewName ); 3039 3040 if(GetModel()->GetDoc()) 3041 GetModel()->GetDoc()->RenameLayoutTemplate(GetPage()->GetLayoutName(), aNewName); 3042 3043 // fake a mode change to repaint the page tab bar 3044 ::sd::DrawDocShell* pDocSh = GetModel()->GetDocShell(); 3045 ::sd::ViewShell* pViewSh = pDocSh ? pDocSh->GetViewShell() : NULL; 3046 if( pViewSh && pViewSh->ISA(::sd::DrawViewShell ) ) 3047 { 3048 ::sd::DrawViewShell* pDrawViewSh = 3049 static_cast< ::sd::DrawViewShell*>(pViewSh); 3050 3051 EditMode eMode = pDrawViewSh->GetEditMode(); 3052 if( eMode == EM_MASTERPAGE ) 3053 { 3054 sal_Bool bLayer = pDrawViewSh->IsLayerModeActive(); 3055 3056 pDrawViewSh->ChangeEditMode( eMode, !bLayer ); 3057 pDrawViewSh->ChangeEditMode( eMode, bLayer ); 3058 } 3059 } 3060 3061 GetModel()->SetModified(); 3062 } 3063 } 3064 3065 OUString SAL_CALL SdMasterPage::getName( ) 3066 { 3067 OGuard aGuard( Application::GetSolarMutex() ); 3068 3069 throwIfDisposed(); 3070 3071 if(SvxFmDrawPage::mpPage) 3072 { 3073 String aLayoutName( GetPage()->GetLayoutName() ); 3074 aLayoutName = aLayoutName.Erase(aLayoutName.Search( String( RTL_CONSTASCII_USTRINGPARAM((SD_LT_SEPARATOR))))); 3075 3076 return aLayoutName; 3077 } 3078 3079 return OUString(); 3080 } 3081 3082 // XPresentationPage 3083 Reference< drawing::XDrawPage > SAL_CALL SdMasterPage::getNotesPage() 3084 { 3085 OGuard aGuard( Application::GetSolarMutex() ); 3086 3087 throwIfDisposed(); 3088 3089 if(SvxFmDrawPage::mpPage && GetModel()->GetDoc() ) 3090 { 3091 SdPage* pNotesPage = GetModel()->GetDoc()->GetMasterSdPage( (SvxFmDrawPage::mpPage->GetPageNum()-1)>>1, PK_NOTES ); 3092 if( pNotesPage ) 3093 { 3094 Reference< drawing::XDrawPage > xPage( pNotesPage->getUnoPage(), uno::UNO_QUERY ); 3095 return xPage; 3096 } 3097 } 3098 return NULL; 3099 } 3100 3101 // XShapes 3102 void SAL_CALL SdMasterPage::add( const Reference< drawing::XShape >& xShape ) 3103 { 3104 SdGenericDrawPage::add( xShape ); 3105 } 3106 3107 void SAL_CALL SdMasterPage::remove( const Reference< drawing::XShape >& xShape ) 3108 { 3109 OGuard aGuard( Application::GetSolarMutex() ); 3110 3111 throwIfDisposed(); 3112 3113 SvxShape* pShape = SvxShape::getImplementation( xShape ); 3114 if( pShape ) 3115 { 3116 SdrObject* pObj = pShape->GetSdrObject(); 3117 if( pObj ) 3118 { 3119 if( GetPage()->IsPresObj( pObj ) ) 3120 GetPage()->RemovePresObj(pObj); 3121 } 3122 } 3123 3124 SdGenericDrawPage::remove( xShape ); 3125 } 3126 3127 3128 Reference< uno::XInterface > createUnoPageImpl( SdPage* pPage ) 3129 { 3130 Reference< uno::XInterface > xPage; 3131 3132 if( pPage && pPage->GetModel() ) 3133 { 3134 SdXImpressDocument* pModel = SdXImpressDocument::getImplementation( pPage->GetModel()->getUnoModel() ); 3135 if( pModel ) 3136 { 3137 if( pPage->IsMasterPage() ) 3138 { 3139 xPage = (::cppu::OWeakObject*)new SdMasterPage( pModel, pPage ); 3140 } 3141 else 3142 { 3143 xPage = (::cppu::OWeakObject*)new SdDrawPage( pModel, pPage ); 3144 } 3145 } 3146 } 3147 3148 return xPage; 3149 } 3150