Files
libreoffice/oox/source/dump/dumperbase.cxx

3183 lines
101 KiB
C++
Raw Normal View History

2008-01-17 07:06:10 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2008-01-17 07:06:10 +00:00
*
* Copyright 2008 by Sun Microsystems, Inc.
2008-01-17 07:06:10 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2008-01-17 07:06:10 +00:00
*
* $RCSfile: dumperbase.cxx,v $
2008-09-30 13:51:36 +00:00
* $Revision: 1.4.20.13 $
2008-01-17 07:06:10 +00:00
*
* This file is part of OpenOffice.org.
2008-01-17 07:06:10 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2008-01-17 07:06:10 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2008-01-17 07:06:10 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2008-01-17 07:06:10 +00:00
*
************************************************************************/
#include "oox/dump/dumperbase.hxx"
#include <algorithm>
2008-01-17 07:06:10 +00:00
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp>
#include <com/sun/star/io/XTextInputStream.hpp>
#include <com/sun/star/io/XTextOutputStream.hpp>
2008-09-30 13:51:36 +00:00
#include <rtl/math.hxx>
#include <osl/file.hxx>
2008-01-17 07:06:10 +00:00
#include "oox/helper/binaryoutputstream.hxx"
#include "oox/core/filterbase.hxx"
#include "oox/xls/biffhelper.hxx"
#if OOX_INCLUDE_DUMPER
2008-09-30 13:51:36 +00:00
using ::rtl::OString;
using ::rtl::OStringBuffer;
using ::rtl::OStringToOUString;
2008-01-17 07:06:10 +00:00
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
2008-09-30 13:51:36 +00:00
using ::rtl::OUStringToOString;
2008-01-17 07:06:10 +00:00
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::util::DateTime;
using ::com::sun::star::lang::XMultiServiceFactory;
using ::com::sun::star::ucb::XSimpleFileAccess;
using ::com::sun::star::io::XActiveDataSink;
using ::com::sun::star::io::XActiveDataSource;
using ::com::sun::star::io::XInputStream;
using ::com::sun::star::io::XTextInputStream;
using ::com::sun::star::io::XOutputStream;
using ::com::sun::star::io::XTextOutputStream;
using ::oox::core::FilterBase;
namespace oox {
namespace dump {
const sal_Unicode OOX_DUMP_BOM = 0xFEFF;
const sal_Int32 OOX_DUMP_MAXSTRLEN = 80;
const sal_Int32 OOX_DUMP_INDENT = 2;
const sal_Unicode OOX_DUMP_BINDOT = '.';
const sal_Unicode OOX_DUMP_CFG_LISTSEP = ',';
const sal_Unicode OOX_DUMP_CFG_QUOTE = '\'';
const sal_Unicode OOX_DUMP_LF = '\n';
const sal_Unicode OOX_DUMP_ITEMSEP = '=';
const sal_Int32 OOX_DUMP_BYTESPERLINE = 16;
2008-09-30 13:51:36 +00:00
const sal_Int64 OOX_DUMP_MAXARRAY = 16;
2008-01-17 07:06:10 +00:00
// ============================================================================
// ============================================================================
// file names -----------------------------------------------------------------
OUString InputOutputHelper::convertFileNameToUrl( const OUString& rFileName )
{
OUString aFileUrl;
if( ::osl::FileBase::getFileURLFromSystemPath( rFileName, aFileUrl ) == ::osl::FileBase::E_None )
return aFileUrl;
return OUString();
}
sal_Int32 InputOutputHelper::getFileNamePos( const OUString& rFileUrl )
{
sal_Int32 nSepPos = rFileUrl.lastIndexOf( '/' );
return (nSepPos < 0) ? 0 : (nSepPos + 1);
}
OUString InputOutputHelper::getFileNameExtension( const OUString& rFileUrl )
{
sal_Int32 nNamePos = getFileNamePos( rFileUrl );
sal_Int32 nExtPos = rFileUrl.lastIndexOf( '.' );
if( nExtPos >= nNamePos )
return rFileUrl.copy( nExtPos + 1 );
return OUString();
}
2008-09-30 13:51:36 +00:00
// input streams --------------------------------------------------------------
Reference< XInputStream > InputOutputHelper::getXInputStream( BinaryInputStream& rStrm )
{
if( BinaryXInputStream* pXStrm = dynamic_cast< BinaryXInputStream* >( &rStrm ) )
return pXStrm->getXInputStream();
return 0;
}
Reference< XInputStream > InputOutputHelper::openInputStream(
const Reference< XMultiServiceFactory >& rxFactory, const OUString& rFileName )
2008-01-17 07:06:10 +00:00
{
Reference< XInputStream > xInStrm;
2008-09-30 13:51:36 +00:00
if( rxFactory.is() ) try
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
Reference< XSimpleFileAccess > xFileAccess( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW );
2008-01-17 07:06:10 +00:00
xInStrm = xFileAccess->openFileRead( rFileName );
}
catch( Exception& )
{
}
return xInStrm;
}
2008-09-30 13:51:36 +00:00
Reference< XTextInputStream > InputOutputHelper::openTextInputStream(
const Reference< XMultiServiceFactory >& rxFactory, const Reference< XInputStream >& rxInStrm, const OUString& rEncoding )
2008-01-17 07:06:10 +00:00
{
Reference< XTextInputStream > xTextInStrm;
2008-09-30 13:51:36 +00:00
if( rxFactory.is() && rxInStrm.is() ) try
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
Reference< XActiveDataSink > xDataSink( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TextInputStream" ) ), UNO_QUERY_THROW );
2008-01-17 07:06:10 +00:00
xDataSink->setInputStream( rxInStrm );
xTextInStrm.set( xDataSink, UNO_QUERY_THROW );
CWS-TOOLING: integrate CWS dr67 2009-04-08 13:23:56 +0200 dr r270638 : #i100534# reverted 2009-04-08 10:14:55 +0200 dr r270621 : CWS-TOOLING: rebase CWS dr67 to trunk@270033 (milestone: DEV300:m45) 2009-04-07 21:06:33 +0200 dr r270610 : #i100534# sc does not link in debug mode 2009-03-12 11:20:09 +0100 dr r269375 : #i10000# wae 2009-03-11 19:43:55 +0100 dr r269351 : #i10000# adjust oox namespace ids according to oox/inc/oox/core/namespaces.hxx 2009-03-11 15:38:52 +0100 dr r269339 : CWS-TOOLING: rebase CWS dr67 to trunk@269297 (milestone: DEV300:m43) 2009-02-27 15:20:21 +0100 dr r268598 : CWS-TOOLING: rebase CWS dr67 to trunk@268395 (milestone: DEV300:m42) 2009-02-19 13:32:17 +0100 dr r268277 : moved hf parser into page settings 2009-02-19 12:25:15 +0100 dr r268272 : renamed some structs according to chart filter 2009-02-16 15:51:31 +0100 dr r267823 : #i97873# import autosort settings from BIFF8/OOBIN/OOXML 2009-02-06 17:09:29 +0100 dr r267477 : #i97873# minor changes 2009-02-06 16:38:56 +0100 dr r267473 : #i97873# import date grouping settings from BIFF5/BIFF8/OOBIN/OOXML 2009-02-06 16:38:11 +0100 dr r267472 : #i97873# check min/max/step of passed GroupInfo 2009-02-06 16:35:13 +0100 dr r267471 : #i97873# more doc for createDategroup() 2009-02-06 13:53:42 +0100 dr r267459 : #i97873# make XDataPilotGrouping::createDateGroup() implementation working and robust against wrong input data 2009-02-06 13:52:16 +0100 dr r267458 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-06 12:35:49 +0100 dr r267453 : fix other IDLC warnings in sheet module 2009-02-06 12:05:19 +0100 dr r267448 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-02 17:58:46 +0100 dr r267284 : #i10000# rebase errors 2009-02-02 17:52:21 +0100 dr r267282 : #i10000# rebase errors 2009-02-02 17:35:58 +0100 dr r267280 : #i10000# rebase errors 2009-02-02 15:58:04 +0100 dr r267274 : CWS-TOOLING: rebase CWS dr67 to trunk@267171 (milestone: DEV300:m41) 2009-02-02 09:16:32 +0100 dr r267247 : #i97873# typo 2009-01-30 17:09:09 +0100 dr r267215 : #i97873# import numeric grouping settings for datapilot fields from BIFF5/BIFF8/OOBIN/OOXML 2009-01-29 16:36:24 +0100 dr r267154 : #i97873# import datapilot discrete grouping from BIFF5/BIFF8/OOBIN/OOXLS 2009-01-29 16:33:37 +0100 dr r267152 : #i97873# do not kill _all_ the other group fields when writing back DataPilotField::GroupInfo property 2009-01-29 14:15:45 +0100 dr r267133 : #i93839# remove ScChengeTrack::Load and ::Store, adapt xls export filter 2009-01-28 13:30:37 +0100 dr r267056 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-28 12:09:05 +0100 dr r267051 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-27 16:13:58 +0100 dr r267005 : #i97873# minor changes in DataPilot API implementation as preparation for additional changes needed for OOX import filter 2009-01-27 10:08:01 +0100 dr r266961 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-27 10:06:50 +0100 dr r266960 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-23 12:52:31 +0100 dr r266808 : #i97873# DP documentation extended 2009-01-21 20:07:15 +0100 dr r266702 : #i97873# this trivial patch adds BIFF5/BIFF8 pivot table import to the oox filter 2009-01-20 16:06:23 +0100 dr r266592 : select BIFF filter via env.var 2009-01-16 18:51:01 +0100 dr r266452 : #i97873# import page fields 2009-01-16 15:05:36 +0100 dr r266420 : #i97873# field item settings (collapsed/hidden), settings of hidden fields 2009-01-15 16:01:17 +0100 dr r266377 : #i97873# import OOXML7/OOBIN7 autoshow settings 2009-01-14 15:24:27 +0100 dr r266310 : #i97873# import auto show settings generated by MSO2003 2009-01-14 12:29:44 +0100 dr r266281 : #i97873# set global dp settings 2009-01-13 15:04:30 +0100 dr r266229 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-13 14:46:50 +0100 dr r266225 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-12 15:04:22 +0100 dr r266161 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 15:03:42 +0100 dr r266160 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 14:57:33 +0100 dr r266159 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-12 14:52:43 +0100 dr r266158 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-09 16:34:55 +0100 dr r266098 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 16:32:16 +0100 dr r266097 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 12:02:39 +0100 dr r266072 : #i97623# RTL handling changed after CWS rtlcontrols 2009-01-09 09:48:53 +0100 dr r266050 : #i158444# SXLI must be filled completely before starting CONTINUE 2009-01-08 18:50:08 +0100 dr r266032 : #158444# allow to disable dump of record positions 2009-01-08 15:46:45 +0100 dr r266020 : #i97873# data layout field handling 2009-01-08 15:45:45 +0100 dr r266019 : #i97873# data layout field handling 2009-01-08 15:42:25 +0100 dr r266018 : #i97873# data layout field handling 2009-01-02 17:28:32 +0100 dr r265844 : #i10000# unxmacxi warning 2009-01-02 16:59:13 +0100 dr r265842 : #i10000# rebase corrections 2009-01-02 16:44:44 +0100 dr r265838 : #i10000# rebase corrections 2009-01-02 11:32:44 +0100 dr r265834 : CWS-TOOLING: rebase CWS dr67 to trunk@265758 (milestone: DEV300:m38) 2008-12-29 16:55:40 +0100 dr r265822 : more pivot table import, field layout settings 2008-12-29 14:27:35 +0100 dr r265817 : more pivot table import, additions for data field settings 2008-12-26 14:39:21 +0100 dr r265805 : updates 2008-12-19 16:31:39 +0100 dr r265734 : typo 2008-12-19 16:30:00 +0100 dr r265733 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:43 +0100 dr r265732 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:07 +0100 dr r265731 : add API for sequence of DP field subtotal functions 2008-12-18 18:07:58 +0100 dr r265710 : #i96758# try to cache row default formatting and apply it at row ranges instead of single rows 2008-12-18 16:00:25 +0100 dr r265698 : more additions to pivot import 2008-12-17 13:38:19 +0100 dr r265599 : do not assert HIDDEN orientation 2008-12-12 13:51:29 +0100 dr r265415 : minor typos 2008-12-12 10:15:04 +0100 dr r265394 : pivot cache import extended to XLSB, added creation of cache data for missing/external sheets 2008-12-04 13:16:16 +0100 dr r264837 : #i96860# remove old dumper files 2008-12-04 12:17:38 +0100 dr r264834 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-04 12:16:38 +0100 dr r264833 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-03 14:51:05 +0100 dr r264784 : #i10000# warnings 2008-12-03 14:32:46 +0100 dr r264778 : #i10000# warning 2008-12-03 11:28:38 +0100 dr r264758 : #i96758# ignore zero-sized objects 2008-12-03 10:09:34 +0100 dr r264748 : #i96758# change ::oox::Property(Set|Map) keys to sal_Int32 property identifiers, to save construction of property names 2008-12-01 16:09:02 +0100 dr r264615 : #i96758# headerdoc 2008-12-01 14:49:04 +0100 dr r264607 : #i96758# import performance of formatted documents 2008-11-26 17:08:15 +0100 dr r264424 : make it more simple 2008-11-26 16:31:41 +0100 dr r264419 : c:crossesAt is for crossing axis, not for own axis. This is different to BIFF 2008-11-26 13:55:55 +0100 dr r264382 : #i86346# import of MissingValueTreatment from XLSX 2008-11-26 12:49:38 +0100 dr r264370 : #i86346# import/export of MissingValueTreatment from/to XLS 2008-11-25 17:48:59 +0100 dr r264320 : update row height with single progress bar when using 'IsAdjustHeightEnabled' document property 2008-11-25 17:24:26 +0100 dr r264319 : #i96438# disable importing comment text until API is fixed 2008-11-25 17:11:30 +0100 dr r264318 : #i90124# set control tooltips, patch from npower 2008-11-25 15:09:28 +0100 dr r264309 : #i94028# #i94991# update drawing objects when changing row height 2008-11-24 15:21:35 +0100 dr r264224 : prevent ::rtl::OUString::copy assertion 2008-11-24 15:19:39 +0100 dr r264223 : #i95183# #158573# handle non-ascii characters in sheet names in OOXML import 2008-11-24 12:54:30 +0100 dr r264221 : #i94157# support ESC key to leave full-screen in page preview 2008-11-21 18:15:17 +0100 dr r264165 : #i90360# disable chart perspective if it is set to 0 2008-11-21 18:14:41 +0100 dr r264164 : #i90360# disable chart perspective if it is set to 0 2008-11-21 17:43:26 +0100 dr r264155 : #i96140# missing parenth 2008-11-21 17:36:35 +0100 dr r264154 : #i96438# first steps of note import 2008-11-20 15:15:03 +0100 dr r264059 : get rid of ContextWrapper 2008-11-18 11:39:52 +0100 dr r263755 : #i78476# moved to CWS dr67
2009-04-22 10:06:26 +00:00
xTextInStrm->setEncoding( rEncoding );
2008-01-17 07:06:10 +00:00
}
catch( Exception& )
{
}
return xTextInStrm;
}
2008-09-30 13:51:36 +00:00
Reference< XTextInputStream > InputOutputHelper::openTextInputStream(
const Reference< XMultiServiceFactory >& rxFactory, const OUString& rFileName, const OUString& rEncoding )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
return openTextInputStream( rxFactory, openInputStream( rxFactory, rFileName ), rEncoding );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
// output streams -------------------------------------------------------------
Reference< XOutputStream > InputOutputHelper::openOutputStream(
const Reference< XMultiServiceFactory >& rxFactory, const OUString& rFileName )
2008-01-17 07:06:10 +00:00
{
Reference< XOutputStream > xOutStrm;
2008-09-30 13:51:36 +00:00
if( rxFactory.is() ) try
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
Reference< XSimpleFileAccess > xFileAccess( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW );
xOutStrm = xFileAccess->openFileWrite( rFileName );
2008-01-17 07:06:10 +00:00
}
catch( Exception& )
{
}
return xOutStrm;
}
2008-09-30 13:51:36 +00:00
Reference< XTextOutputStream > InputOutputHelper::openTextOutputStream(
const Reference< XMultiServiceFactory >& rxFactory, const Reference< XOutputStream >& rxOutStrm, const OUString& rEncoding )
2008-01-17 07:06:10 +00:00
{
Reference< XTextOutputStream > xTextOutStrm;
2008-09-30 13:51:36 +00:00
if( rxFactory.is() && rxOutStrm.is() ) try
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
Reference< XActiveDataSource > xDataSource( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.io.TextOutputStream" ) ), UNO_QUERY_THROW );
2008-01-17 07:06:10 +00:00
xDataSource->setOutputStream( rxOutStrm );
xTextOutStrm.set( xDataSource, UNO_QUERY_THROW );
CWS-TOOLING: integrate CWS dr67 2009-04-08 13:23:56 +0200 dr r270638 : #i100534# reverted 2009-04-08 10:14:55 +0200 dr r270621 : CWS-TOOLING: rebase CWS dr67 to trunk@270033 (milestone: DEV300:m45) 2009-04-07 21:06:33 +0200 dr r270610 : #i100534# sc does not link in debug mode 2009-03-12 11:20:09 +0100 dr r269375 : #i10000# wae 2009-03-11 19:43:55 +0100 dr r269351 : #i10000# adjust oox namespace ids according to oox/inc/oox/core/namespaces.hxx 2009-03-11 15:38:52 +0100 dr r269339 : CWS-TOOLING: rebase CWS dr67 to trunk@269297 (milestone: DEV300:m43) 2009-02-27 15:20:21 +0100 dr r268598 : CWS-TOOLING: rebase CWS dr67 to trunk@268395 (milestone: DEV300:m42) 2009-02-19 13:32:17 +0100 dr r268277 : moved hf parser into page settings 2009-02-19 12:25:15 +0100 dr r268272 : renamed some structs according to chart filter 2009-02-16 15:51:31 +0100 dr r267823 : #i97873# import autosort settings from BIFF8/OOBIN/OOXML 2009-02-06 17:09:29 +0100 dr r267477 : #i97873# minor changes 2009-02-06 16:38:56 +0100 dr r267473 : #i97873# import date grouping settings from BIFF5/BIFF8/OOBIN/OOXML 2009-02-06 16:38:11 +0100 dr r267472 : #i97873# check min/max/step of passed GroupInfo 2009-02-06 16:35:13 +0100 dr r267471 : #i97873# more doc for createDategroup() 2009-02-06 13:53:42 +0100 dr r267459 : #i97873# make XDataPilotGrouping::createDateGroup() implementation working and robust against wrong input data 2009-02-06 13:52:16 +0100 dr r267458 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-06 12:35:49 +0100 dr r267453 : fix other IDLC warnings in sheet module 2009-02-06 12:05:19 +0100 dr r267448 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-02 17:58:46 +0100 dr r267284 : #i10000# rebase errors 2009-02-02 17:52:21 +0100 dr r267282 : #i10000# rebase errors 2009-02-02 17:35:58 +0100 dr r267280 : #i10000# rebase errors 2009-02-02 15:58:04 +0100 dr r267274 : CWS-TOOLING: rebase CWS dr67 to trunk@267171 (milestone: DEV300:m41) 2009-02-02 09:16:32 +0100 dr r267247 : #i97873# typo 2009-01-30 17:09:09 +0100 dr r267215 : #i97873# import numeric grouping settings for datapilot fields from BIFF5/BIFF8/OOBIN/OOXML 2009-01-29 16:36:24 +0100 dr r267154 : #i97873# import datapilot discrete grouping from BIFF5/BIFF8/OOBIN/OOXLS 2009-01-29 16:33:37 +0100 dr r267152 : #i97873# do not kill _all_ the other group fields when writing back DataPilotField::GroupInfo property 2009-01-29 14:15:45 +0100 dr r267133 : #i93839# remove ScChengeTrack::Load and ::Store, adapt xls export filter 2009-01-28 13:30:37 +0100 dr r267056 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-28 12:09:05 +0100 dr r267051 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-27 16:13:58 +0100 dr r267005 : #i97873# minor changes in DataPilot API implementation as preparation for additional changes needed for OOX import filter 2009-01-27 10:08:01 +0100 dr r266961 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-27 10:06:50 +0100 dr r266960 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-23 12:52:31 +0100 dr r266808 : #i97873# DP documentation extended 2009-01-21 20:07:15 +0100 dr r266702 : #i97873# this trivial patch adds BIFF5/BIFF8 pivot table import to the oox filter 2009-01-20 16:06:23 +0100 dr r266592 : select BIFF filter via env.var 2009-01-16 18:51:01 +0100 dr r266452 : #i97873# import page fields 2009-01-16 15:05:36 +0100 dr r266420 : #i97873# field item settings (collapsed/hidden), settings of hidden fields 2009-01-15 16:01:17 +0100 dr r266377 : #i97873# import OOXML7/OOBIN7 autoshow settings 2009-01-14 15:24:27 +0100 dr r266310 : #i97873# import auto show settings generated by MSO2003 2009-01-14 12:29:44 +0100 dr r266281 : #i97873# set global dp settings 2009-01-13 15:04:30 +0100 dr r266229 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-13 14:46:50 +0100 dr r266225 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-12 15:04:22 +0100 dr r266161 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 15:03:42 +0100 dr r266160 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 14:57:33 +0100 dr r266159 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-12 14:52:43 +0100 dr r266158 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-09 16:34:55 +0100 dr r266098 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 16:32:16 +0100 dr r266097 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 12:02:39 +0100 dr r266072 : #i97623# RTL handling changed after CWS rtlcontrols 2009-01-09 09:48:53 +0100 dr r266050 : #i158444# SXLI must be filled completely before starting CONTINUE 2009-01-08 18:50:08 +0100 dr r266032 : #158444# allow to disable dump of record positions 2009-01-08 15:46:45 +0100 dr r266020 : #i97873# data layout field handling 2009-01-08 15:45:45 +0100 dr r266019 : #i97873# data layout field handling 2009-01-08 15:42:25 +0100 dr r266018 : #i97873# data layout field handling 2009-01-02 17:28:32 +0100 dr r265844 : #i10000# unxmacxi warning 2009-01-02 16:59:13 +0100 dr r265842 : #i10000# rebase corrections 2009-01-02 16:44:44 +0100 dr r265838 : #i10000# rebase corrections 2009-01-02 11:32:44 +0100 dr r265834 : CWS-TOOLING: rebase CWS dr67 to trunk@265758 (milestone: DEV300:m38) 2008-12-29 16:55:40 +0100 dr r265822 : more pivot table import, field layout settings 2008-12-29 14:27:35 +0100 dr r265817 : more pivot table import, additions for data field settings 2008-12-26 14:39:21 +0100 dr r265805 : updates 2008-12-19 16:31:39 +0100 dr r265734 : typo 2008-12-19 16:30:00 +0100 dr r265733 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:43 +0100 dr r265732 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:07 +0100 dr r265731 : add API for sequence of DP field subtotal functions 2008-12-18 18:07:58 +0100 dr r265710 : #i96758# try to cache row default formatting and apply it at row ranges instead of single rows 2008-12-18 16:00:25 +0100 dr r265698 : more additions to pivot import 2008-12-17 13:38:19 +0100 dr r265599 : do not assert HIDDEN orientation 2008-12-12 13:51:29 +0100 dr r265415 : minor typos 2008-12-12 10:15:04 +0100 dr r265394 : pivot cache import extended to XLSB, added creation of cache data for missing/external sheets 2008-12-04 13:16:16 +0100 dr r264837 : #i96860# remove old dumper files 2008-12-04 12:17:38 +0100 dr r264834 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-04 12:16:38 +0100 dr r264833 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-03 14:51:05 +0100 dr r264784 : #i10000# warnings 2008-12-03 14:32:46 +0100 dr r264778 : #i10000# warning 2008-12-03 11:28:38 +0100 dr r264758 : #i96758# ignore zero-sized objects 2008-12-03 10:09:34 +0100 dr r264748 : #i96758# change ::oox::Property(Set|Map) keys to sal_Int32 property identifiers, to save construction of property names 2008-12-01 16:09:02 +0100 dr r264615 : #i96758# headerdoc 2008-12-01 14:49:04 +0100 dr r264607 : #i96758# import performance of formatted documents 2008-11-26 17:08:15 +0100 dr r264424 : make it more simple 2008-11-26 16:31:41 +0100 dr r264419 : c:crossesAt is for crossing axis, not for own axis. This is different to BIFF 2008-11-26 13:55:55 +0100 dr r264382 : #i86346# import of MissingValueTreatment from XLSX 2008-11-26 12:49:38 +0100 dr r264370 : #i86346# import/export of MissingValueTreatment from/to XLS 2008-11-25 17:48:59 +0100 dr r264320 : update row height with single progress bar when using 'IsAdjustHeightEnabled' document property 2008-11-25 17:24:26 +0100 dr r264319 : #i96438# disable importing comment text until API is fixed 2008-11-25 17:11:30 +0100 dr r264318 : #i90124# set control tooltips, patch from npower 2008-11-25 15:09:28 +0100 dr r264309 : #i94028# #i94991# update drawing objects when changing row height 2008-11-24 15:21:35 +0100 dr r264224 : prevent ::rtl::OUString::copy assertion 2008-11-24 15:19:39 +0100 dr r264223 : #i95183# #158573# handle non-ascii characters in sheet names in OOXML import 2008-11-24 12:54:30 +0100 dr r264221 : #i94157# support ESC key to leave full-screen in page preview 2008-11-21 18:15:17 +0100 dr r264165 : #i90360# disable chart perspective if it is set to 0 2008-11-21 18:14:41 +0100 dr r264164 : #i90360# disable chart perspective if it is set to 0 2008-11-21 17:43:26 +0100 dr r264155 : #i96140# missing parenth 2008-11-21 17:36:35 +0100 dr r264154 : #i96438# first steps of note import 2008-11-20 15:15:03 +0100 dr r264059 : get rid of ContextWrapper 2008-11-18 11:39:52 +0100 dr r263755 : #i78476# moved to CWS dr67
2009-04-22 10:06:26 +00:00
xTextOutStrm->setEncoding( rEncoding );
2008-01-17 07:06:10 +00:00
}
catch( Exception& )
{
}
return xTextOutStrm;
}
2008-09-30 13:51:36 +00:00
Reference< XTextOutputStream > InputOutputHelper::openTextOutputStream(
const Reference< XMultiServiceFactory >& rxFactory, const OUString& rFileName, const OUString& rEncoding )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
return openTextOutputStream( rxFactory, openOutputStream( rxFactory, rFileName ), rEncoding );
2008-01-17 07:06:10 +00:00
}
// ============================================================================
// ============================================================================
ItemFormat::ItemFormat() :
meDataType( DATATYPE_VOID ),
meFmtType( FORMATTYPE_NONE )
{
}
void ItemFormat::set( DataType eDataType, FormatType eFmtType, const OUString& rItemName )
{
meDataType = eDataType;
meFmtType = eFmtType;
maItemName = rItemName;
maListName = OUString();
}
void ItemFormat::set( DataType eDataType, FormatType eFmtType, const OUString& rItemName, const OUString& rListName )
{
set( eDataType, eFmtType, rItemName );
maListName = rListName;
}
OUStringVector::const_iterator ItemFormat::parse( const OUStringVector& rFormatVec )
{
set( DATATYPE_VOID, FORMATTYPE_NONE, OUString() );
OUStringVector::const_iterator aIt = rFormatVec.begin(), aEnd = rFormatVec.end();
OUString aDataType, aFmtType;
if( aIt != aEnd ) aDataType = *aIt++;
if( aIt != aEnd ) aFmtType = *aIt++;
if( aIt != aEnd ) maItemName = *aIt++;
if( aIt != aEnd ) maListName = *aIt++;
meDataType = StringHelper::convertToDataType( aDataType );
meFmtType = StringHelper::convertToFormatType( aFmtType );
if( meFmtType == FORMATTYPE_NONE )
{
if( aFmtType.equalsAscii( "unused" ) )
set( meDataType, FORMATTYPE_HEX, CREATE_OUSTRING( OOX_DUMP_UNUSED ) );
else if( aFmtType.equalsAscii( "unknown" ) )
set( meDataType, FORMATTYPE_HEX, CREATE_OUSTRING( OOX_DUMP_UNKNOWN ) );
}
return aIt;
}
OUStringVector ItemFormat::parse( const OUString& rFormatStr )
{
OUStringVector aFormatVec;
StringHelper::convertStringToStringList( aFormatVec, rFormatStr, false );
OUStringVector::const_iterator aIt = parse( aFormatVec );
return OUStringVector( aIt, const_cast< const OUStringVector& >( aFormatVec ).end() );
}
// ============================================================================
// ============================================================================
// append string to string ----------------------------------------------------
2008-09-30 13:51:36 +00:00
void StringHelper::appendChar( OUStringBuffer& rStr, sal_Unicode cChar, sal_Int32 nCount )
2008-01-17 07:06:10 +00:00
{
for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex )
rStr.append( cChar );
}
void StringHelper::appendString( OUStringBuffer& rStr, const OUString& rData, sal_Int32 nWidth, sal_Unicode cFill )
{
appendChar( rStr, cFill, nWidth - rData.getLength() );
rStr.append( rData );
}
// append decimal -------------------------------------------------------------
void StringHelper::appendDec( OUStringBuffer& rStr, sal_uInt8 nData, sal_Int32 nWidth, sal_Unicode cFill )
{
appendString( rStr, OUString::valueOf( static_cast< sal_Int32 >( nData ) ), nWidth, cFill );
}
void StringHelper::appendDec( OUStringBuffer& rStr, sal_Int8 nData, sal_Int32 nWidth, sal_Unicode cFill )
{
appendString( rStr, OUString::valueOf( static_cast< sal_Int32 >( nData ) ), nWidth, cFill );
}
void StringHelper::appendDec( OUStringBuffer& rStr, sal_uInt16 nData, sal_Int32 nWidth, sal_Unicode cFill )
{
appendString( rStr, OUString::valueOf( static_cast< sal_Int32 >( nData ) ), nWidth, cFill );
}
void StringHelper::appendDec( OUStringBuffer& rStr, sal_Int16 nData, sal_Int32 nWidth, sal_Unicode cFill )
{
appendString( rStr, OUString::valueOf( static_cast< sal_Int32 >( nData ) ), nWidth, cFill );
}
void StringHelper::appendDec( OUStringBuffer& rStr, sal_uInt32 nData, sal_Int32 nWidth, sal_Unicode cFill )
{
appendString( rStr, OUString::valueOf( static_cast< sal_Int64 >( nData ) ), nWidth, cFill );
}
void StringHelper::appendDec( OUStringBuffer& rStr, sal_Int32 nData, sal_Int32 nWidth, sal_Unicode cFill )
{
appendString( rStr, OUString::valueOf( nData ), nWidth, cFill );
}
void StringHelper::appendDec( OUStringBuffer& rStr, sal_uInt64 nData, sal_Int32 nWidth, sal_Unicode cFill )
{
/* Values greater than biggest signed 64bit integer will change to
negative when converting to sal_Int64. Therefore, the trailing digit
will be written separately. */
OUStringBuffer aBuffer;
if( nData > 9 )
aBuffer.append( OUString::valueOf( static_cast< sal_Int64 >( nData / 10 ) ) );
aBuffer.append( static_cast< sal_Unicode >( '0' + (nData % 10) ) );
appendString( rStr, aBuffer.makeStringAndClear(), nWidth, cFill );
}
void StringHelper::appendDec( OUStringBuffer& rStr, sal_Int64 nData, sal_Int32 nWidth, sal_Unicode cFill )
{
appendString( rStr, OUString::valueOf( nData ), nWidth, cFill );
}
void StringHelper::appendDec( OUStringBuffer& rStr, double fData, sal_Int32 nWidth, sal_Unicode cFill )
{
appendString( rStr, ::rtl::math::doubleToUString( fData, rtl_math_StringFormat_G, 15, '.', true ), nWidth, cFill );
}
// append hexadecimal ---------------------------------------------------------
void StringHelper::appendHex( OUStringBuffer& rStr, sal_uInt8 nData, bool bPrefix )
{
static const sal_Unicode spcHexDigits[] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' };
if( bPrefix )
rStr.appendAscii( "0x" );
rStr.append( spcHexDigits[ (nData >> 4) & 0x0F ] ).append( spcHexDigits[ nData & 0x0F ] );
}
void StringHelper::appendHex( OUStringBuffer& rStr, sal_Int8 nData, bool bPrefix )
{
appendHex( rStr, static_cast< sal_uInt8 >( nData ), bPrefix );
}
void StringHelper::appendHex( OUStringBuffer& rStr, sal_uInt16 nData, bool bPrefix )
{
appendHex( rStr, static_cast< sal_uInt8 >( nData >> 8 ), bPrefix );
appendHex( rStr, static_cast< sal_uInt8 >( nData ), false );
}
void StringHelper::appendHex( OUStringBuffer& rStr, sal_Int16 nData, bool bPrefix )
{
appendHex( rStr, static_cast< sal_uInt16 >( nData ), bPrefix );
}
void StringHelper::appendHex( OUStringBuffer& rStr, sal_uInt32 nData, bool bPrefix )
{
appendHex( rStr, static_cast< sal_uInt16 >( nData >> 16 ), bPrefix );
appendHex( rStr, static_cast< sal_uInt16 >( nData ), false );
}
void StringHelper::appendHex( OUStringBuffer& rStr, sal_Int32 nData, bool bPrefix )
{
appendHex( rStr, static_cast< sal_uInt32 >( nData ), bPrefix );
}
void StringHelper::appendHex( OUStringBuffer& rStr, sal_uInt64 nData, bool bPrefix )
{
appendHex( rStr, static_cast< sal_uInt32 >( nData >> 32 ), bPrefix );
appendHex( rStr, static_cast< sal_uInt32 >( nData ), false );
}
void StringHelper::appendHex( OUStringBuffer& rStr, sal_Int64 nData, bool bPrefix )
{
appendHex( rStr, static_cast< sal_uInt64 >( nData ), bPrefix );
}
void StringHelper::appendHex( OUStringBuffer& rStr, double fData, bool bPrefix )
{
appendHex( rStr, *reinterpret_cast< const sal_uInt64* >( &fData ), bPrefix );
}
// append shortened hexadecimal -----------------------------------------------
void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_uInt8 nData, bool bPrefix )
{
2008-09-30 13:51:36 +00:00
appendHex( rStr, nData, bPrefix );
2008-01-17 07:06:10 +00:00
}
void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_Int8 nData, bool bPrefix )
{
2008-09-30 13:51:36 +00:00
appendHex( rStr, nData, bPrefix );
2008-01-17 07:06:10 +00:00
}
void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_uInt16 nData, bool bPrefix )
{
2008-09-30 13:51:36 +00:00
if( nData > SAL_MAX_UINT8 )
2008-01-17 07:06:10 +00:00
appendHex( rStr, nData, bPrefix );
else
2008-09-30 13:51:36 +00:00
appendHex( rStr, static_cast< sal_uInt8 >( nData ), bPrefix );
2008-01-17 07:06:10 +00:00
}
void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_Int16 nData, bool bPrefix )
{
appendShortHex( rStr, static_cast< sal_uInt16 >( nData ), bPrefix );
}
void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_uInt32 nData, bool bPrefix )
{
2008-09-30 13:51:36 +00:00
if( nData > SAL_MAX_UINT16 )
2008-01-17 07:06:10 +00:00
appendHex( rStr, nData, bPrefix );
else
appendShortHex( rStr, static_cast< sal_uInt16 >( nData ), bPrefix );
}
void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_Int32 nData, bool bPrefix )
{
appendShortHex( rStr, static_cast< sal_uInt32 >( nData ), bPrefix );
}
void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_uInt64 nData, bool bPrefix )
{
2008-09-30 13:51:36 +00:00
if( nData > SAL_MAX_UINT32 )
2008-01-17 07:06:10 +00:00
appendHex( rStr, nData, bPrefix );
else
appendShortHex( rStr, static_cast< sal_uInt32 >( nData ), bPrefix );
}
void StringHelper::appendShortHex( OUStringBuffer& rStr, sal_Int64 nData, bool bPrefix )
{
appendShortHex( rStr, static_cast< sal_uInt64 >( nData ), bPrefix );
}
2008-09-30 13:51:36 +00:00
void StringHelper::appendShortHex( OUStringBuffer& rStr, double fData, bool bPrefix )
{
appendHex( rStr, fData, bPrefix );
}
2008-01-17 07:06:10 +00:00
// append binary --------------------------------------------------------------
void StringHelper::appendBin( OUStringBuffer& rStr, sal_uInt8 nData, bool bDots )
{
for( sal_uInt8 nMask = 0x80; nMask != 0; (nMask >>= 1) &= 0x7F )
{
rStr.append( static_cast< sal_Unicode >( (nData & nMask) ? '1' : '0' ) );
if( bDots && (nMask == 0x10) )
rStr.append( OOX_DUMP_BINDOT );
}
}
void StringHelper::appendBin( OUStringBuffer& rStr, sal_Int8 nData, bool bDots )
{
appendBin( rStr, static_cast< sal_uInt8 >( nData ), bDots );
}
void StringHelper::appendBin( OUStringBuffer& rStr, sal_uInt16 nData, bool bDots )
{
appendBin( rStr, static_cast< sal_uInt8 >( nData >> 8 ), bDots );
if( bDots )
rStr.append( OOX_DUMP_BINDOT );
appendBin( rStr, static_cast< sal_uInt8 >( nData ), bDots );
}
void StringHelper::appendBin( OUStringBuffer& rStr, sal_Int16 nData, bool bDots )
{
appendBin( rStr, static_cast< sal_uInt16 >( nData ), bDots );
}
void StringHelper::appendBin( OUStringBuffer& rStr, sal_uInt32 nData, bool bDots )
{
appendBin( rStr, static_cast< sal_uInt16 >( nData >> 16 ), bDots );
if( bDots )
rStr.append( OOX_DUMP_BINDOT );
appendBin( rStr, static_cast< sal_uInt16 >( nData ), bDots );
}
void StringHelper::appendBin( OUStringBuffer& rStr, sal_Int32 nData, bool bDots )
{
appendBin( rStr, static_cast< sal_uInt32 >( nData ), bDots );
}
void StringHelper::appendBin( OUStringBuffer& rStr, sal_uInt64 nData, bool bDots )
{
appendBin( rStr, static_cast< sal_uInt32 >( nData >> 32 ), bDots );
if( bDots )
rStr.append( OOX_DUMP_BINDOT );
appendBin( rStr, static_cast< sal_uInt32 >( nData ), bDots );
}
void StringHelper::appendBin( OUStringBuffer& rStr, sal_Int64 nData, bool bDots )
{
appendBin( rStr, static_cast< sal_uInt64 >( nData ), bDots );
}
void StringHelper::appendBin( OUStringBuffer& rStr, double fData, bool bDots )
{
appendBin( rStr, *reinterpret_cast< const sal_uInt64* >( &fData ), bDots );
}
// append formatted value -----------------------------------------------------
void StringHelper::appendBool( OUStringBuffer& rStr, bool bData )
{
rStr.appendAscii( bData ? "true" : "false" );
}
// append columns, rows, addresses --------------------------------------------
void StringHelper::appendAddrCol( OUStringBuffer& rStr, sal_Int32 nCol, bool bRel )
{
if( !bRel ) rStr.append( OOX_DUMP_ADDRABS );
sal_Int32 nPos = rStr.getLength();
for( sal_Int32 nTemp = nCol; nTemp >= 0; (nTemp /= 26) -= 1 )
rStr.insert( nPos, static_cast< sal_Unicode >( 'A' + (nTemp % 26) ) );
}
void StringHelper::appendAddrRow( OUStringBuffer& rStr, sal_Int32 nRow, bool bRel )
{
if( !bRel ) rStr.append( OOX_DUMP_ADDRABS );
appendDec( rStr, nRow + 1 );
}
void StringHelper::appendAddrName( OUStringBuffer& rStr, sal_Unicode cPrefix, sal_Int32 nColRow, bool bRel )
{
rStr.append( cPrefix );
if( bRel && (nColRow != 0) )
{
rStr.append( OOX_DUMP_R1C1OPEN );
appendDec( rStr, nColRow );
rStr.append( OOX_DUMP_R1C1CLOSE );
}
else if( !bRel )
appendDec( rStr, nColRow + 1 );
}
void StringHelper::appendAddress( OUStringBuffer& rStr, const Address& rPos )
{
appendAddrCol( rStr, rPos.mnCol, true );
appendAddrRow( rStr, rPos.mnRow, true );
}
void StringHelper::appendRange( OUStringBuffer& rStr, const Range& rRange )
{
appendAddress( rStr, rRange.maFirst );
rStr.append( OOX_DUMP_RANGESEP );
appendAddress( rStr, rRange.maLast );
}
void StringHelper::appendRangeList( OUStringBuffer& rStr, const RangeList& rRanges )
{
OUStringBuffer aData;
for( RangeList::const_iterator aIt = rRanges.begin(), aEnd = rRanges.end(); aIt != aEnd; ++aIt )
{
OUStringBuffer aRange;
appendRange( aRange, *aIt );
appendToken( aData, aRange.makeStringAndClear(), OOX_DUMP_LISTSEP );
}
rStr.append( aData.makeStringAndClear() );
}
void StringHelper::appendAddress( OUStringBuffer& rStr, const TokenAddress& rPos, bool bR1C1 )
{
if( bR1C1 && (rPos.mbRelCol || rPos.mbRelRow) )
{
appendAddrName( rStr, OOX_DUMP_R1C1ROW, rPos.mnRow, rPos.mbRelRow );
appendAddrName( rStr, OOX_DUMP_R1C1COL, rPos.mnCol, rPos.mbRelCol );
}
else
{
appendAddrCol( rStr, rPos.mnCol, rPos.mbRelCol );
appendAddrRow( rStr, rPos.mnRow, rPos.mbRelRow );
}
}
void StringHelper::appendRange( OUStringBuffer& rStr, const TokenRange& rRange, bool bR1C1 )
{
appendAddress( rStr, rRange.maFirst, bR1C1 );
rStr.append( OOX_DUMP_RANGESEP );
appendAddress( rStr, rRange.maLast, bR1C1 );
}
// encoded text output --------------------------------------------------------
void StringHelper::appendCChar( OUStringBuffer& rStr, sal_Unicode cChar, bool bPrefix )
{
if( cChar > 0x00FF )
{
if( bPrefix )
rStr.appendAscii( "\\u" );
appendHex( rStr, static_cast< sal_uInt16 >( cChar ), false );
}
else
{
if( bPrefix )
rStr.appendAscii( "\\x" );
appendHex( rStr, static_cast< sal_uInt8 >( cChar ), false );
}
}
void StringHelper::appendEncChar( OUStringBuffer& rStr, sal_Unicode cChar, sal_Int32 nCount, bool bPrefix )
{
if( cChar < 0x0020 )
{
// C-style hex code
OUStringBuffer aCode;
appendCChar( aCode, cChar, bPrefix );
for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx )
rStr.append( aCode );
}
else
{
appendChar( rStr, cChar, nCount );
}
}
void StringHelper::appendEncString( OUStringBuffer& rStr, const OUString& rData, bool bPrefix )
{
sal_Int32 nBeg = 0;
sal_Int32 nIdx = 0;
sal_Int32 nEnd = rData.getLength();
while( nIdx < nEnd )
{
// find next character that needs encoding
while( (nIdx < nEnd) && (rData[ nIdx ] >= 0x20) ) ++nIdx;
// append portion
if( nBeg < nIdx )
{
if( (nBeg == 0) && (nIdx == nEnd) )
rStr.append( rData );
else
rStr.append( rData.copy( nBeg, nIdx - nBeg ) );
}
// append characters to be encoded
while( (nIdx < nEnd) && (rData[ nIdx ] < 0x20) )
{
appendCChar( rStr, rData[ nIdx ], bPrefix );
++nIdx;
}
// adjust limits
nBeg = nIdx;
}
}
// token list -----------------------------------------------------------------
void StringHelper::appendToken( OUStringBuffer& rStr, const OUString& rToken, sal_Unicode cSep )
{
if( (rStr.getLength() > 0) && (rToken.getLength() > 0) )
rStr.append( cSep );
rStr.append( rToken );
}
void StringHelper::appendToken( OUStringBuffer& rStr, sal_Int64 nToken, sal_Unicode cSep )
{
OUStringBuffer aToken;
appendDec( aToken, nToken );
appendToken( rStr, aToken.makeStringAndClear(), cSep );
}
void StringHelper::prependToken( OUStringBuffer& rStr, const OUString& rToken, sal_Unicode cSep )
{
if( (rStr.getLength() > 0) && (rToken.getLength() > 0) )
rStr.insert( 0, cSep );
rStr.insert( 0, rToken );
}
void StringHelper::prependToken( OUStringBuffer& rStr, sal_Int64 nToken, sal_Unicode cSep )
{
OUStringBuffer aToken;
appendDec( aToken, nToken );
prependToken( rStr, aToken.makeStringAndClear(), cSep );
}
void StringHelper::appendIndex( OUStringBuffer& rStr, const OUString& rIdx )
{
rStr.append( sal_Unicode( '[' ) ).append( rIdx ).append( sal_Unicode( ']' ) );
}
void StringHelper::appendIndex( OUStringBuffer& rStr, sal_Int64 nIdx )
{
OUStringBuffer aToken;
appendDec( aToken, nIdx );
appendIndex( rStr, aToken.makeStringAndClear() );
}
void StringHelper::appendIndexedText( OUStringBuffer& rStr, const OUString& rData, const OUString& rIdx )
{
rStr.append( rData );
appendIndex( rStr, rIdx );
}
void StringHelper::appendIndexedText( OUStringBuffer& rStr, const OUString& rData, sal_Int64 nIdx )
{
rStr.append( rData );
appendIndex( rStr, nIdx );
}
OUString StringHelper::getToken( const OUString& rData, sal_Int32& rnPos, sal_Unicode cSep )
{
return trimSpaces( rData.getToken( 0, cSep, rnPos ) );
}
void StringHelper::enclose( OUStringBuffer& rStr, sal_Unicode cOpen, sal_Unicode cClose )
{
rStr.insert( 0, cOpen ).append( cClose ? cClose : cOpen );
}
// string conversion ----------------------------------------------------------
namespace {
sal_Int32 lclIndexOf( const OUString& rStr, sal_Unicode cChar, sal_Int32 nStartPos )
{
sal_Int32 nIndex = rStr.indexOf( cChar, nStartPos );
return (nIndex < 0) ? rStr.getLength() : nIndex;
}
OUString lclTrimQuotedStringList( const OUString& rStr )
{
OUStringBuffer aBuffer;
sal_Int32 nPos = 0;
sal_Int32 nLen = rStr.getLength();
while( nPos < nLen )
{
if( rStr[ nPos ] == OOX_DUMP_CFG_QUOTE )
{
// quoted string, skip leading quote character
++nPos;
// process quoted text and ambedded literal quote characters
OUStringBuffer aToken;
do
{
// seek to next quote character and add text portion to token buffer
sal_Int32 nEnd = lclIndexOf( rStr, OOX_DUMP_CFG_QUOTE, nPos );
aToken.append( rStr.copy( nPos, nEnd - nPos ) );
// process literal quotes
while( (nEnd + 1 < nLen) && (rStr[ nEnd ] == OOX_DUMP_CFG_QUOTE) && (rStr[ nEnd + 1 ] == OOX_DUMP_CFG_QUOTE) )
{
aToken.append( OOX_DUMP_CFG_QUOTE );
nEnd += 2;
}
// nEnd is start of possible next text portion
nPos = nEnd;
}
while( (nPos < nLen) && (rStr[ nPos ] != OOX_DUMP_CFG_QUOTE) );
// add token, seek to list separator, ignore text following closing quote
aBuffer.append( aToken.makeStringAndClear() );
nPos = lclIndexOf( rStr, OOX_DUMP_CFG_LISTSEP, nPos );
if( nPos < nLen )
aBuffer.append( OOX_DUMP_LF );
// set current position behind list separator
++nPos;
}
else
{
// find list separator, add token text to buffer
sal_Int32 nEnd = lclIndexOf( rStr, OOX_DUMP_CFG_LISTSEP, nPos );
aBuffer.append( rStr.copy( nPos, nEnd - nPos ) );
if( nEnd < nLen )
aBuffer.append( OOX_DUMP_LF );
// set current position behind list separator
nPos = nEnd + 1;
}
}
return aBuffer.makeStringAndClear();
}
} // namespace
OUString StringHelper::trimSpaces( const OUString& rStr )
{
sal_Int32 nBeg = 0;
while( (nBeg < rStr.getLength()) && ((rStr[ nBeg ] == ' ') || (rStr[ nBeg ] == '\t')) )
++nBeg;
sal_Int32 nEnd = rStr.getLength();
while( (nEnd > nBeg) && ((rStr[ nEnd - 1 ] == ' ') || (rStr[ nEnd - 1 ] == '\t')) )
--nEnd;
return rStr.copy( nBeg, nEnd - nBeg );
}
OString StringHelper::convertToUtf8( const OUString& rStr )
{
2008-09-30 13:51:36 +00:00
return OUStringToOString( rStr, RTL_TEXTENCODING_UTF8 );
2008-01-17 07:06:10 +00:00
}
DataType StringHelper::convertToDataType( const OUString& rStr )
{
DataType eType = DATATYPE_VOID;
if( rStr.equalsAscii( "int8" ) )
eType = DATATYPE_INT8;
else if( rStr.equalsAscii( "uint8" ) )
eType = DATATYPE_UINT8;
else if( rStr.equalsAscii( "int16" ) )
eType = DATATYPE_INT16;
else if( rStr.equalsAscii( "uint16" ) )
eType = DATATYPE_UINT16;
else if( rStr.equalsAscii( "int32" ) )
eType = DATATYPE_INT32;
else if( rStr.equalsAscii( "uint32" ) )
eType = DATATYPE_UINT32;
else if( rStr.equalsAscii( "int64" ) )
eType = DATATYPE_INT64;
else if( rStr.equalsAscii( "uint64" ) )
eType = DATATYPE_UINT64;
else if( rStr.equalsAscii( "float" ) )
eType = DATATYPE_FLOAT;
else if( rStr.equalsAscii( "double" ) )
eType = DATATYPE_DOUBLE;
return eType;
}
FormatType StringHelper::convertToFormatType( const OUString& rStr )
{
FormatType eType = FORMATTYPE_NONE;
if( rStr.equalsAscii( "dec" ) )
eType = FORMATTYPE_DEC;
else if( rStr.equalsAscii( "hex" ) )
eType = FORMATTYPE_HEX;
2008-09-30 13:51:36 +00:00
else if( rStr.equalsAscii( "shorthex" ) )
eType = FORMATTYPE_SHORTHEX;
2008-01-17 07:06:10 +00:00
else if( rStr.equalsAscii( "bin" ) )
eType = FORMATTYPE_BIN;
else if( rStr.equalsAscii( "fix" ) )
eType = FORMATTYPE_FIX;
else if( rStr.equalsAscii( "bool" ) )
eType = FORMATTYPE_BOOL;
return eType;
}
bool StringHelper::convertFromDec( sal_Int64& ornData, const OUString& rData )
{
sal_Int32 nPos = 0;
sal_Int32 nLen = rData.getLength();
bool bNeg = false;
if( (nLen > 0) && (rData[ 0 ] == '-') )
{
bNeg = true;
++nPos;
}
ornData = 0;
for( ; nPos < nLen; ++nPos )
{
sal_Unicode cChar = rData[ nPos ];
if( (cChar < '0') || (cChar > '9') )
return false;
(ornData *= 10) += (cChar - '0');
}
if( bNeg )
ornData *= -1;
return true;
}
bool StringHelper::convertFromHex( sal_Int64& ornData, const OUString& rData )
{
ornData = 0;
for( sal_Int32 nPos = 0, nLen = rData.getLength(); nPos < nLen; ++nPos )
{
sal_Unicode cChar = rData[ nPos ];
if( ('0' <= cChar) && (cChar <= '9') )
cChar -= '0';
else if( ('A' <= cChar) && (cChar <= 'F') )
cChar -= ('A' - 10);
else if( ('a' <= cChar) && (cChar <= 'f') )
cChar -= ('a' - 10);
else
return false;
(ornData <<= 4) += cChar;
}
return true;
}
bool StringHelper::convertStringToInt( sal_Int64& ornData, const OUString& rData )
{
if( (rData.getLength() > 2) && (rData[ 0 ] == '0') && ((rData[ 1 ] == 'X') || (rData[ 1 ] == 'x')) )
return convertFromHex( ornData, rData.copy( 2 ) );
return convertFromDec( ornData, rData );
}
bool StringHelper::convertStringToDouble( double& orfData, const OUString& rData )
{
rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
sal_Int32 nSize = 0;
orfData = rtl::math::stringToDouble( rData, '.', '\0', &eStatus, &nSize );
return (eStatus == rtl_math_ConversionStatus_Ok) && (nSize == rData.getLength());
}
bool StringHelper::convertStringToBool( const OUString& rData )
{
if( rData.equalsAscii( "true" ) )
return true;
if( rData.equalsAscii( "false" ) )
return false;
sal_Int64 nData;
return convertStringToInt( nData, rData ) && (nData != 0);
}
void StringHelper::convertStringToStringList( OUStringVector& orVec, const OUString& rData, bool bIgnoreEmpty )
{
orVec.clear();
OUString aUnquotedData = lclTrimQuotedStringList( rData );
sal_Int32 nPos = 0;
sal_Int32 nLen = aUnquotedData.getLength();
while( (0 <= nPos) && (nPos < nLen) )
{
OUString aToken = getToken( aUnquotedData, nPos, OOX_DUMP_LF );
if( !bIgnoreEmpty || (aToken.getLength() > 0) )
orVec.push_back( aToken );
}
}
void StringHelper::convertStringToIntList( Int64Vector& orVec, const OUString& rData, bool bIgnoreEmpty )
{
orVec.clear();
OUString aUnquotedData = lclTrimQuotedStringList( rData );
sal_Int32 nPos = 0;
sal_Int32 nLen = aUnquotedData.getLength();
sal_Int64 nData;
while( (0 <= nPos) && (nPos < nLen) )
{
bool bOk = convertStringToInt( nData, getToken( aUnquotedData, nPos, OOX_DUMP_LF ) );
if( !bIgnoreEmpty || bOk )
orVec.push_back( bOk ? nData : 0 );
}
}
// ============================================================================
// ============================================================================
FormulaStack::FormulaStack() :
mbError( false )
{
}
2008-09-30 13:51:36 +00:00
void FormulaStack::pushOperand( const String& rOp, const OUString& rTokClass )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
maFmlaStack.push( rOp );
2008-01-17 07:06:10 +00:00
maClassStack.push( rTokClass );
}
2008-09-30 13:51:36 +00:00
void FormulaStack::pushOperand( const String& rOp )
2008-01-17 07:06:10 +00:00
{
pushOperand( rOp, OUString( OOX_DUMP_BASECLASS ) );
}
2008-09-30 13:51:36 +00:00
void FormulaStack::pushUnaryOp( const String& rLOp, const String& rROp )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
pushUnaryOp( maFmlaStack, rLOp, rROp );
pushUnaryOp( maClassStack, rLOp, rROp );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void FormulaStack::pushBinaryOp( const String& rOp )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
pushBinaryOp( maFmlaStack, rOp );
pushBinaryOp( maClassStack, rOp );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void FormulaStack::pushFuncOp( const String& rFunc, const OUString& rTokClass, sal_uInt8 nParamCount )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
pushFuncOp( maFmlaStack, rFunc, nParamCount );
2008-01-17 07:06:10 +00:00
pushFuncOp( maClassStack, rTokClass, nParamCount );
}
void FormulaStack::replaceOnTop( const OUString& rOld, const OUString& rNew )
{
if( !maFmlaStack.empty() )
{
sal_Int32 nPos = maFmlaStack.top().indexOf( rOld );
if( nPos >= 0 )
maFmlaStack.top() = maFmlaStack.top().copy( 0, nPos ) + rNew + maFmlaStack.top().copy( nPos + rOld.getLength() );
}
}
const OUString& FormulaStack::getString( const StringStack& rStack ) const
{
static const OUString saStackError = OOX_DUMP_ERRSTRING( "stack" );
return (mbError || rStack.empty()) ? saStackError : rStack.top();
}
void FormulaStack::pushUnaryOp( StringStack& rStack, const OUString& rLOp, const OUString& rROp )
{
if( check( !rStack.empty() ) )
rStack.top() = rLOp + rStack.top() + rROp;
}
void FormulaStack::pushBinaryOp( StringStack& rStack, const OUString& rOp )
{
OUString aSecond;
if( check( !rStack.empty() ) )
{
aSecond = rStack.top();
rStack.pop();
}
if( check( !rStack.empty() ) )
rStack.top() = rStack.top() + rOp + aSecond;
}
void FormulaStack::pushFuncOp( StringStack& rStack, const OUString& rOp, sal_uInt8 nParamCount )
{
OUStringBuffer aFunc;
for( sal_uInt8 nParam = 0; (nParam < nParamCount) && check( !rStack.empty() ); ++nParam )
{
StringHelper::prependToken( aFunc, rStack.top(), OOX_DUMP_FUNCSEP );
rStack.pop();
}
StringHelper::enclose( aFunc, '(', ')' );
aFunc.insert( 0, rOp );
rStack.push( aFunc.makeStringAndClear() );
}
// ============================================================================
// ============================================================================
Base::~Base()
{
}
// ============================================================================
// ============================================================================
ConfigItemBase::~ConfigItemBase()
{
}
void ConfigItemBase::readConfigBlock( const ConfigInputStreamRef& rxStrm )
{
readConfigBlockContents( rxStrm );
}
void ConfigItemBase::implProcessConfigItemStr(
const ConfigInputStreamRef& /*rxStrm*/, const OUString& /*rKey*/, const OUString& /*rData*/ )
{
}
void ConfigItemBase::implProcessConfigItemInt(
const ConfigInputStreamRef& /*rxStrm*/, sal_Int64 /*nKey*/, const OUString& /*rData*/ )
{
}
void ConfigItemBase::readConfigBlockContents( const ConfigInputStreamRef& rxStrm )
{
bool bLoop = true;
while( bLoop && !rxStrm->isEOF() )
{
OUString aKey, aData;
switch( readConfigLine( rxStrm, aKey, aData ) )
{
case LINETYPE_DATA:
processConfigItem( rxStrm, aKey, aData );
break;
case LINETYPE_END:
bLoop = false;
break;
}
}
}
ConfigItemBase::LineType ConfigItemBase::readConfigLine(
const ConfigInputStreamRef& rxStrm, OUString& orKey, OUString& orData ) const
{
OUString aLine;
while( !rxStrm->isEOF() && (aLine.getLength() == 0) )
{
try { aLine = rxStrm->readLine(); } catch( Exception& ) { aLine = OUString(); }
if( (aLine.getLength() > 0) && (aLine[ 0 ] == OOX_DUMP_BOM) )
aLine = aLine.copy( 1 );
aLine = StringHelper::trimSpaces( aLine );
if( aLine.getLength() > 0 )
{
// ignore comments (starting with hash or semicolon)
sal_Unicode cChar = aLine[ 0 ];
if( (cChar == '#') || (cChar == ';') )
aLine = OUString();
}
}
LineType eResult = LINETYPE_END;
if( aLine.getLength() > 0 )
{
sal_Int32 nEqPos = aLine.indexOf( '=' );
if( nEqPos < 0 )
{
orKey = aLine;
}
else
{
orKey = StringHelper::trimSpaces( aLine.copy( 0, nEqPos ) );
orData = StringHelper::trimSpaces( aLine.copy( nEqPos + 1 ) );
}
if( (orKey.getLength() > 0) && ((orData.getLength() > 0) || !orKey.equalsAscii( "end" )) )
eResult = LINETYPE_DATA;
}
return eResult;
}
ConfigItemBase::LineType ConfigItemBase::readConfigLine( const ConfigInputStreamRef& rxStrm ) const
{
OUString aKey, aData;
return readConfigLine( rxStrm, aKey, aData );
}
void ConfigItemBase::processConfigItem(
const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData )
{
sal_Int64 nKey;
if( StringHelper::convertStringToInt( nKey, rKey ) )
implProcessConfigItemInt( rxStrm, nKey, rData );
else
implProcessConfigItemStr( rxStrm, rKey, rData );
}
// ============================================================================
NameListBase::~NameListBase()
{
}
2008-09-30 13:51:36 +00:00
void NameListBase::setName( sal_Int64 nKey, const String& rName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
implSetName( nKey, rName );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void NameListBase::includeList( const NameListRef& rxList )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
if( rxList.get() )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
for( const_iterator aIt = rxList->begin(), aEnd = rxList->end(); aIt != aEnd; ++aIt )
2008-01-17 07:06:10 +00:00
maMap[ aIt->first ] = aIt->second;
2008-09-30 13:51:36 +00:00
implIncludeList( *rxList );
2008-01-17 07:06:10 +00:00
}
}
bool NameListBase::implIsValid() const
{
return true;
}
void NameListBase::implProcessConfigItemStr(
const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData )
{
if( rKey.equalsAscii( "include" ) )
include( rData );
else if( rKey.equalsAscii( "exclude" ) )
exclude( rData );
else
ConfigItemBase::implProcessConfigItemStr( rxStrm, rKey, rData );
}
void NameListBase::implProcessConfigItemInt(
const ConfigInputStreamRef& /*rxStrm*/, sal_Int64 nKey, const OUString& rData )
{
implSetName( nKey, rData );
}
void NameListBase::insertRawName( sal_Int64 nKey, const OUString& rName )
{
maMap[ nKey ] = rName;
}
const OUString* NameListBase::findRawName( sal_Int64 nKey ) const
{
const_iterator aIt = maMap.find( nKey );
return (aIt == end()) ? 0 : &aIt->second;
}
void NameListBase::include( const OUString& rListKeys )
{
OUStringVector aVec;
StringHelper::convertStringToStringList( aVec, rListKeys, true );
for( OUStringVector::const_iterator aIt = aVec.begin(), aEnd = aVec.end(); aIt != aEnd; ++aIt )
includeList( mrCfgData.getNameList( *aIt ) );
}
void NameListBase::exclude( const OUString& rKeys )
{
Int64Vector aVec;
StringHelper::convertStringToIntList( aVec, rKeys, true );
for( Int64Vector::const_iterator aIt = aVec.begin(), aEnd = aVec.end(); aIt != aEnd; ++aIt )
maMap.erase( *aIt );
}
// ============================================================================
ConstList::ConstList( const SharedConfigData& rCfgData ) :
NameListBase( rCfgData ),
maDefName( OOX_DUMP_ERR_NONAME ),
mbQuoteNames( false )
{
}
void ConstList::implProcessConfigItemStr(
const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData )
{
if( rKey.equalsAscii( "default" ) )
setDefaultName( rData );
else if( rKey.equalsAscii( "quote-names" ) )
setQuoteNames( StringHelper::convertStringToBool( rData ) );
else
NameListBase::implProcessConfigItemStr( rxStrm, rKey, rData );
}
void ConstList::implSetName( sal_Int64 nKey, const OUString& rName )
{
insertRawName( nKey, rName );
}
OUString ConstList::implGetName( const Config& /*rCfg*/, sal_Int64 nKey ) const
{
const OUString* pName = findRawName( nKey );
OUString aName = pName ? *pName : maDefName;
if( mbQuoteNames )
{
OUStringBuffer aBuffer( aName );
StringHelper::enclose( aBuffer, OOX_DUMP_STRQUOTE );
aName = aBuffer.makeStringAndClear();
}
return aName;
}
OUString ConstList::implGetNameDbl( const Config& /*rCfg*/, double /*fValue*/ ) const
{
return OUString();
}
void ConstList::implIncludeList( const NameListBase& rList )
{
if( const ConstList* pConstList = dynamic_cast< const ConstList* >( &rList ) )
{
maDefName = pConstList->maDefName;
mbQuoteNames = pConstList->mbQuoteNames;
}
}
// ============================================================================
MultiList::MultiList( const SharedConfigData& rCfgData ) :
ConstList( rCfgData ),
mbIgnoreEmpty( true )
{
}
void MultiList::setNamesFromVec( sal_Int64 nStartKey, const OUStringVector& rNames )
{
sal_Int64 nKey = nStartKey;
for( OUStringVector::const_iterator aIt = rNames.begin(), aEnd = rNames.end(); aIt != aEnd; ++aIt, ++nKey )
if( !mbIgnoreEmpty || (aIt->getLength() > 0) )
insertRawName( nKey, *aIt );
}
void MultiList::implProcessConfigItemStr(
const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData )
{
if( rKey.equalsAscii( "ignore-empty" ) )
mbIgnoreEmpty = StringHelper::convertStringToBool( rData );
else
ConstList::implProcessConfigItemStr( rxStrm, rKey, rData );
}
void MultiList::implSetName( sal_Int64 nKey, const OUString& rName )
{
OUStringVector aNames;
StringHelper::convertStringToStringList( aNames, rName, false );
setNamesFromVec( nKey, aNames );
}
// ============================================================================
FlagsList::FlagsList( const SharedConfigData& rCfgData ) :
NameListBase( rCfgData ),
mnIgnore( 0 )
{
}
void FlagsList::implProcessConfigItemStr(
const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData )
{
if( rKey.equalsAscii( "ignore" ) )
{
sal_Int64 nIgnore;
if( StringHelper::convertStringToInt( nIgnore, rData ) )
setIgnoreFlags( nIgnore );
}
else
{
NameListBase::implProcessConfigItemStr( rxStrm, rKey, rData );
}
}
void FlagsList::implSetName( sal_Int64 nKey, const OUString& rName )
{
insertRawName( nKey, rName );
}
OUString FlagsList::implGetName( const Config& /*rCfg*/, sal_Int64 nKey ) const
{
sal_Int64 nFlags = nKey;
setFlag( nFlags, mnIgnore, false );
sal_Int64 nFound = 0;
OUStringBuffer aName;
// add known flags
for( const_iterator aIt = begin(), aEnd = end(); aIt != aEnd; ++aIt )
{
sal_Int64 nMask = aIt->first;
const OUString& rFlagName = aIt->second;
bool bNegated = (rFlagName.getLength() > 0) && (rFlagName[ 0 ] == '!');
2008-09-30 13:51:36 +00:00
sal_Int32 nBothSep = bNegated ? rFlagName.indexOf( '!', 1 ) : -1;
bool bFlag = getFlag( nFlags, nMask );
if( bFlag )
{
if( !bNegated )
StringHelper::appendToken( aName, rFlagName );
else if( nBothSep > 0 )
StringHelper::appendToken( aName, rFlagName.copy( nBothSep + 1 ) );
}
else if( bNegated )
{
if( nBothSep > 0 )
StringHelper::appendToken( aName, rFlagName.copy( 1, nBothSep - 1 ) );
else
StringHelper::appendToken( aName, rFlagName.copy( 1 ) );
}
2008-01-17 07:06:10 +00:00
setFlag( nFound, nMask );
}
// add unknown flags
setFlag( nFlags, nFound, false );
if( nFlags != 0 )
{
OUStringBuffer aUnknown( CREATE_OUSTRING( OOX_DUMP_UNKNOWN ) );
aUnknown.append( OOX_DUMP_ITEMSEP );
StringHelper::appendShortHex( aUnknown, nFlags, true );
StringHelper::enclose( aUnknown, '(', ')' );
StringHelper::appendToken( aName, aUnknown.makeStringAndClear() );
}
return aName.makeStringAndClear();
}
OUString FlagsList::implGetNameDbl( const Config& /*rCfg*/, double /*fValue*/ ) const
{
return OUString();
}
void FlagsList::implIncludeList( const NameListBase& rList )
{
if( const FlagsList* pFlagsList = dynamic_cast< const FlagsList* >( &rList ) )
mnIgnore = pFlagsList->mnIgnore;
}
// ============================================================================
CombiList::CombiList( const SharedConfigData& rCfgData ) :
FlagsList( rCfgData )
{
}
void CombiList::implSetName( sal_Int64 nKey, const OUString& rName )
{
if( (nKey & (nKey - 1)) != 0 ) // more than a single bit set?
{
ExtItemFormat& rItemFmt = maFmtMap[ nKey ];
OUStringVector aRemain = rItemFmt.parse( rName );
rItemFmt.mbShiftValue = aRemain.empty() || !aRemain.front().equalsAscii( "noshift" );
}
else
{
FlagsList::implSetName( nKey, rName );
}
}
OUString CombiList::implGetName( const Config& rCfg, sal_Int64 nKey ) const
{
sal_Int64 nFlags = nKey;
sal_Int64 nFound = 0;
OUStringBuffer aName;
// add known flag fields
for( ExtItemFormatMap::const_iterator aIt = maFmtMap.begin(), aEnd = maFmtMap.end(); aIt != aEnd; ++aIt )
{
sal_Int64 nMask = aIt->first;
if( nMask != 0 )
{
const ExtItemFormat& rItemFmt = aIt->second;
sal_uInt64 nUFlags = static_cast< sal_uInt64 >( nFlags );
sal_uInt64 nUMask = static_cast< sal_uInt64 >( nMask );
if( rItemFmt.mbShiftValue )
while( (nUMask & 1) == 0 ) { nUFlags >>= 1; nUMask >>= 1; }
sal_uInt64 nUValue = nUFlags & nUMask;
sal_Int64 nSValue = static_cast< sal_Int64 >( nUValue );
if( getFlag< sal_uInt64 >( nUValue, (nUMask + 1) >> 1 ) )
setFlag( nSValue, static_cast< sal_Int64 >( ~nUMask ) );
OUStringBuffer aItem( rItemFmt.maItemName );
OUStringBuffer aValue;
switch( rItemFmt.meDataType )
{
case DATATYPE_INT8: StringHelper::appendValue( aValue, static_cast< sal_Int8 >( nSValue ), rItemFmt.meFmtType ); break;
case DATATYPE_UINT8: StringHelper::appendValue( aValue, static_cast< sal_uInt8 >( nUValue ), rItemFmt.meFmtType ); break;
case DATATYPE_INT16: StringHelper::appendValue( aValue, static_cast< sal_Int16 >( nSValue ), rItemFmt.meFmtType ); break;
case DATATYPE_UINT16: StringHelper::appendValue( aValue, static_cast< sal_uInt16 >( nUValue ), rItemFmt.meFmtType ); break;
case DATATYPE_INT32: StringHelper::appendValue( aValue, static_cast< sal_Int32 >( nSValue ), rItemFmt.meFmtType ); break;
case DATATYPE_UINT32: StringHelper::appendValue( aValue, static_cast< sal_uInt32 >( nUValue ), rItemFmt.meFmtType ); break;
case DATATYPE_INT64: StringHelper::appendValue( aValue, nSValue, rItemFmt.meFmtType ); break;
case DATATYPE_UINT64: StringHelper::appendValue( aValue, nUValue, rItemFmt.meFmtType ); break;
case DATATYPE_FLOAT: StringHelper::appendValue( aValue, static_cast< float >( nSValue ), rItemFmt.meFmtType ); break;
case DATATYPE_DOUBLE: StringHelper::appendValue( aValue, static_cast< double >( nSValue ), rItemFmt.meFmtType ); break;
default:;
}
StringHelper::appendToken( aItem, aValue.makeStringAndClear(), OOX_DUMP_ITEMSEP );
if( rItemFmt.maListName.getLength() > 0 )
{
OUString aValueName = rCfg.getName( rItemFmt.maListName, static_cast< sal_Int64 >( nUValue ) );
StringHelper::appendToken( aItem, aValueName, OOX_DUMP_ITEMSEP );
}
StringHelper::enclose( aItem, '(', ')' );
StringHelper::appendToken( aName, aItem.makeStringAndClear() );
setFlag( nFound, nMask );
}
}
setFlag( nFlags, nFound, false );
StringHelper::appendToken( aName, FlagsList::implGetName( rCfg, nFlags ) );
return aName.makeStringAndClear();
}
void CombiList::implIncludeList( const NameListBase& rList )
{
if( const CombiList* pCombiList = dynamic_cast< const CombiList* >( &rList ) )
maFmtMap = pCombiList->maFmtMap;
FlagsList::implIncludeList( rList );
}
// ============================================================================
UnitConverter::UnitConverter( const SharedConfigData& rCfgData ) :
NameListBase( rCfgData ),
mfFactor( 1.0 )
{
}
void UnitConverter::implSetName( sal_Int64 /*nKey*/, const OUString& /*rName*/ )
{
// nothing to do
}
OUString UnitConverter::implGetName( const Config& rCfg, sal_Int64 nKey ) const
{
return implGetNameDbl( rCfg, static_cast< double >( nKey ) );
}
OUString UnitConverter::implGetNameDbl( const Config& /*rCfg*/, double fValue ) const
{
OUStringBuffer aValue;
StringHelper::appendDec( aValue, mfFactor * fValue );
aValue.append( maUnitName );
return aValue.makeStringAndClear();
}
void UnitConverter::implIncludeList( const NameListBase& /*rList*/ )
{
}
// ============================================================================
NameListRef NameListWrapper::getNameList( const Config& rCfg ) const
{
2008-09-30 13:51:36 +00:00
return mxList.get() ? mxList : (mxList = rCfg.getNameList( maName ));
2008-01-17 07:06:10 +00:00
}
// ============================================================================
// ============================================================================
2008-09-30 13:51:36 +00:00
SharedConfigData::SharedConfigData( const OUString& rFileName,
const Reference< XMultiServiceFactory >& rxFactory, const StorageRef& rxRootStrg, const OUString& rSysFileName ) :
mxFactory( rxFactory ),
mxRootStrg( rxRootStrg ),
maSysFileName( rSysFileName ),
mbLoaded( false )
2008-01-17 07:06:10 +00:00
{
OUString aFileUrl = InputOutputHelper::convertFileNameToUrl( rFileName );
if( aFileUrl.getLength() > 0 )
{
sal_Int32 nNamePos = InputOutputHelper::getFileNamePos( aFileUrl );
maConfigPath = aFileUrl.copy( 0, nNamePos );
mbLoaded = readConfigFile( aFileUrl );
}
}
2008-09-30 13:51:36 +00:00
SharedConfigData::~SharedConfigData()
{
}
2008-01-17 07:06:10 +00:00
void SharedConfigData::setOption( const OUString& rKey, const OUString& rData )
{
maConfigData[ rKey ] = rData;
}
const OUString* SharedConfigData::getOption( const OUString& rKey ) const
{
ConfigDataMap::const_iterator aIt = maConfigData.find( rKey );
return (aIt == maConfigData.end()) ? 0 : &aIt->second;
}
2008-09-30 13:51:36 +00:00
void SharedConfigData::setNameList( const OUString& rListName, const NameListRef& rxList )
2008-01-17 07:06:10 +00:00
{
if( rListName.getLength() > 0 )
2008-09-30 13:51:36 +00:00
maNameLists[ rListName ] = rxList;
2008-01-17 07:06:10 +00:00
}
void SharedConfigData::eraseNameList( const OUString& rListName )
{
maNameLists.erase( rListName );
}
NameListRef SharedConfigData::getNameList( const OUString& rListName ) const
{
NameListRef xList;
NameListMap::const_iterator aIt = maNameLists.find( rListName );
if( aIt != maNameLists.end() )
xList = aIt->second;
return xList;
}
bool SharedConfigData::implIsValid() const
{
2008-09-30 13:51:36 +00:00
return mbLoaded && mxFactory.is() && mxRootStrg.get() && (maSysFileName.getLength() > 0);
2008-01-17 07:06:10 +00:00
}
void SharedConfigData::implProcessConfigItemStr(
const ConfigInputStreamRef& rxStrm, const OUString& rKey, const OUString& rData )
{
if( rKey.equalsAscii( "include-config-file" ) )
readConfigFile( maConfigPath + rData );
else if( rKey.equalsAscii( "constlist" ) )
readNameList< ConstList >( rxStrm, rData );
else if( rKey.equalsAscii( "multilist" ) )
readNameList< MultiList >( rxStrm, rData );
else if( rKey.equalsAscii( "flagslist" ) )
readNameList< FlagsList >( rxStrm, rData );
else if( rKey.equalsAscii( "combilist" ) )
readNameList< CombiList >( rxStrm, rData );
else if( rKey.equalsAscii( "shortlist" ) )
createShortList( rData );
else if( rKey.equalsAscii( "unitconverter" ) )
createUnitConverter( rData );
else
setOption( rKey, rData );
}
bool SharedConfigData::readConfigFile( const OUString& rFileUrl )
{
bool bLoaded = maConfigFiles.count( rFileUrl ) > 0;
if( !bLoaded )
2008-01-17 07:06:10 +00:00
{
Reference< XTextInputStream > xTextInStrm =
2008-09-30 13:51:36 +00:00
InputOutputHelper::openTextInputStream( mxFactory, rFileUrl, CREATE_OUSTRING( "UTF-8" ) );
if( xTextInStrm.is() )
{
maConfigFiles.insert( rFileUrl );
readConfigBlockContents( xTextInStrm );
bLoaded = true;
}
2008-01-17 07:06:10 +00:00
}
return bLoaded;
}
void SharedConfigData::createShortList( const OUString& rData )
{
OUStringVector aDataVec;
StringHelper::convertStringToStringList( aDataVec, rData, false );
if( aDataVec.size() >= 3 )
{
sal_Int64 nStartKey;
if( StringHelper::convertStringToInt( nStartKey, aDataVec[ 1 ] ) )
{
::boost::shared_ptr< MultiList > xList = createNameList< MultiList >( aDataVec[ 0 ] );
if( xList.get() )
{
aDataVec.erase( aDataVec.begin(), aDataVec.begin() + 2 );
xList->setNamesFromVec( nStartKey, aDataVec );
}
}
}
}
void SharedConfigData::createUnitConverter( const OUString& rData )
{
OUStringVector aDataVec;
StringHelper::convertStringToStringList( aDataVec, rData, false );
if( aDataVec.size() >= 2 )
{
OUString aFactor = aDataVec[ 1 ];
bool bRecip = (aFactor.getLength() > 0) && (aFactor[ 0 ] == '/');
if( bRecip )
aFactor = aFactor.copy( 1 );
double fFactor;
if( StringHelper::convertStringToDouble( fFactor, aFactor ) && (fFactor != 0.0) )
{
::boost::shared_ptr< UnitConverter > xList = createNameList< UnitConverter >( aDataVec[ 0 ] );
if( xList.get() )
{
xList->setFactor( bRecip ? (1.0 / fFactor) : fFactor );
if( aDataVec.size() >= 3 )
xList->setUnitName( aDataVec[ 2 ] );
}
}
}
}
// ============================================================================
Config::Config( const Config& rParent ) :
Base() // c'tor needs to be called explicitly to avoid compiler warning
{
construct( rParent );
}
2008-09-30 13:51:36 +00:00
Config::Config( const sal_Char* pcEnvVar, const FilterBase& rFilter )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
construct( pcEnvVar, rFilter );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
Config::Config( const sal_Char* pcEnvVar, const Reference< XMultiServiceFactory >& rxFactory, const StorageRef& rxRootStrg, const OUString& rSysFileName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
construct( pcEnvVar, rxFactory, rxRootStrg, rSysFileName );
2008-01-17 07:06:10 +00:00
}
Config::~Config()
{
}
void Config::construct( const Config& rParent )
{
*this = rParent;
}
2008-09-30 13:51:36 +00:00
void Config::construct( const sal_Char* pcEnvVar, const FilterBase& rFilter )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
if( rFilter.getFileUrl().getLength() > 0 )
construct( pcEnvVar, rFilter.getGlobalFactory(), rFilter.getStorage(), rFilter.getFileUrl() );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void Config::construct( const sal_Char* pcEnvVar, const Reference< XMultiServiceFactory >& rxFactory, const StorageRef& rxRootStrg, const OUString& rSysFileName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
if( pcEnvVar && rxRootStrg.get() && (rSysFileName.getLength() > 0) )
2008-01-17 07:06:10 +00:00
if( const sal_Char* pcFileName = ::getenv( pcEnvVar ) )
2008-09-30 13:51:36 +00:00
mxCfgData.reset( new SharedConfigData( OUString::createFromAscii( pcFileName ), rxFactory, rxRootStrg, rSysFileName ) );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void Config::setStringOption( const String& rKey, const String& rData )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
mxCfgData->setOption( rKey, rData );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
const OUString& Config::getStringOption( const String& rKey, const OUString& rDefault ) const
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
const OUString* pData = implGetOption( rKey );
2008-01-17 07:06:10 +00:00
return pData ? *pData : rDefault;
}
2008-09-30 13:51:36 +00:00
bool Config::getBoolOption( const String& rKey, bool bDefault ) const
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
const OUString* pData = implGetOption( rKey );
2008-01-17 07:06:10 +00:00
return pData ? StringHelper::convertStringToBool( *pData ) : bDefault;
}
bool Config::isDumperEnabled() const
{
return getBoolOption( "enable-dumper", false );
}
bool Config::isImportEnabled() const
{
return getBoolOption( "enable-import", true );
}
2008-09-30 13:51:36 +00:00
void Config::setNameList( const String& rListName, const NameListRef& rxList )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
mxCfgData->setNameList( rListName, rxList );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void Config::eraseNameList( const String& rListName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
mxCfgData->eraseNameList( rListName );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
NameListRef Config::getNameList( const String& rListName ) const
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
return implGetNameList( rListName );
2008-01-17 07:06:10 +00:00
}
bool Config::implIsValid() const
{
return isValid( mxCfgData );
}
const OUString* Config::implGetOption( const OUString& rKey ) const
{
return mxCfgData->getOption( rKey );
}
NameListRef Config::implGetNameList( const OUString& rListName ) const
{
return mxCfgData->getNameList( rListName );
}
// ============================================================================
// ============================================================================
Output::Output( const Reference< XTextOutputStream >& rxStrm )
{
construct( rxStrm );
}
2008-09-30 13:51:36 +00:00
Output::Output( const Reference< XMultiServiceFactory >& rxFactory, const OUString& rFileName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
construct( InputOutputHelper::openTextOutputStream( rxFactory, rFileName, CREATE_OUSTRING( "UTF-8" ) ) );
2008-01-17 07:06:10 +00:00
}
// ----------------------------------------------------------------------------
void Output::newLine()
{
if( maLine.getLength() > 0 )
{
mxStrm->writeString( maIndent );
maLine.append( sal_Unicode( '\n' ) );
mxStrm->writeString( maLine.makeStringAndClear() );
mnCol = 0;
mnLastItem = 0;
}
}
void Output::emptyLine( size_t nCount )
{
for( size_t nIdx = 0; nIdx < nCount; ++nIdx )
mxStrm->writeString( OUString( sal_Unicode( '\n' ) ) );
}
void Output::incIndent()
{
OUStringBuffer aBuffer( maIndent );
StringHelper::appendChar( aBuffer, ' ', OOX_DUMP_INDENT );
maIndent = aBuffer.makeStringAndClear();
}
void Output::decIndent()
{
if( maIndent.getLength() >= OOX_DUMP_INDENT )
maIndent = maIndent.copy( OOX_DUMP_INDENT );
}
void Output::resetIndent()
{
maIndent = OUString();
}
void Output::startTable( sal_Int32 nW1 )
{
startTable( 1, &nW1 );
}
void Output::startTable( sal_Int32 nW1, sal_Int32 nW2 )
{
sal_Int32 pnColWidths[ 2 ];
pnColWidths[ 0 ] = nW1;
pnColWidths[ 1 ] = nW2;
startTable( 2, pnColWidths );
}
void Output::startTable( sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3 )
{
sal_Int32 pnColWidths[ 3 ];
pnColWidths[ 0 ] = nW1;
pnColWidths[ 1 ] = nW2;
pnColWidths[ 2 ] = nW3;
startTable( 3, pnColWidths );
}
void Output::startTable( sal_Int32 nW1, sal_Int32 nW2, sal_Int32 nW3, sal_Int32 nW4 )
{
sal_Int32 pnColWidths[ 4 ];
pnColWidths[ 0 ] = nW1;
pnColWidths[ 1 ] = nW2;
pnColWidths[ 2 ] = nW3;
pnColWidths[ 3 ] = nW4;
startTable( 4, pnColWidths );
}
void Output::startTable( size_t nColCount, const sal_Int32* pnColWidths )
{
maColPos.clear();
maColPos.push_back( 0 );
sal_Int32 nColPos = 0;
for( size_t nCol = 0; nCol < nColCount; ++nCol )
{
nColPos = nColPos + pnColWidths[ nCol ];
maColPos.push_back( nColPos );
}
}
void Output::tab()
{
tab( mnCol + 1 );
}
void Output::tab( size_t nCol )
{
mnCol = nCol;
if( mnCol < maColPos.size() )
{
sal_Int32 nColPos = maColPos[ mnCol ];
if( maLine.getLength() >= nColPos )
maLine.setLength( ::std::max< sal_Int32 >( nColPos - 1, 0 ) );
StringHelper::appendChar( maLine, ' ', nColPos - maLine.getLength() );
}
else
{
StringHelper::appendChar( maLine, ' ', 2 );
}
}
void Output::endTable()
{
maColPos.clear();
}
void Output::resetItemIndex( sal_Int64 nIdx )
{
mnItemIdx = nIdx;
}
2008-09-30 13:51:36 +00:00
void Output::startItem( const String& rItemName )
2008-01-17 07:06:10 +00:00
{
if( mnItemLevel == 0 )
{
if( (mnMultiLevel > 0) && (maLine.getLength() > 0) )
tab();
2008-09-30 13:51:36 +00:00
if( rItemName.has() )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
writeItemName( rItemName );
2008-01-17 07:06:10 +00:00
writeChar( OOX_DUMP_ITEMSEP );
}
}
++mnItemLevel;
mnLastItem = maLine.getLength();
}
void Output::contItem()
{
if( mnItemLevel > 0 )
{
if( (maLine.getLength() == 0) || (maLine[ maLine.getLength() - 1 ] != OOX_DUMP_ITEMSEP) )
writeChar( OOX_DUMP_ITEMSEP );
mnLastItem = maLine.getLength();
}
}
void Output::endItem()
{
if( mnItemLevel > 0 )
{
maLastItem = OUString( maLine.getStr() + mnLastItem );
if( (maLastItem.getLength() == 0) && (mnLastItem > 0) && (maLine[ mnLastItem - 1 ] == OOX_DUMP_ITEMSEP) )
maLine.setLength( mnLastItem - 1 );
--mnItemLevel;
}
if( mnItemLevel == 0 )
{
if( mnMultiLevel == 0 )
newLine();
}
else
contItem();
}
void Output::startMultiItems()
{
++mnMultiLevel;
}
void Output::endMultiItems()
{
if( mnMultiLevel > 0 )
--mnMultiLevel;
if( mnMultiLevel == 0 )
newLine();
}
// ----------------------------------------------------------------------------
void Output::writeChar( sal_Unicode cChar, sal_Int32 nCount )
{
StringHelper::appendEncChar( maLine, cChar, nCount );
}
void Output::writeAscii( const sal_Char* pcStr )
{
if( pcStr )
maLine.appendAscii( pcStr );
}
void Output::writeString( const OUString& rStr )
{
StringHelper::appendEncString( maLine, rStr );
}
void Output::writeArray( const sal_uInt8* pnData, sal_Size nSize, sal_Unicode cSep )
{
const sal_uInt8* pnEnd = pnData ? (pnData + nSize) : 0;
for( const sal_uInt8* pnByte = pnData; pnByte < pnEnd; ++pnByte )
{
if( pnByte > pnData )
writeChar( cSep );
writeHex( *pnByte, false );
}
}
void Output::writeBool( bool bData )
{
StringHelper::appendBool( maLine, bData );
}
2008-09-30 13:51:36 +00:00
void Output::writeColorABGR( sal_Int32 nColor )
2008-01-17 07:06:10 +00:00
{
writeChar( 'a' );
writeDec( static_cast< sal_uInt8 >( nColor >> 24 ) );
writeAscii( ",r" );
2008-09-30 13:51:36 +00:00
writeDec( static_cast< sal_uInt8 >( nColor ) );
2008-01-17 07:06:10 +00:00
writeAscii( ",g" );
writeDec( static_cast< sal_uInt8 >( nColor >> 8 ) );
writeAscii( ",b" );
2008-09-30 13:51:36 +00:00
writeDec( static_cast< sal_uInt8 >( nColor >> 16 ) );
2008-01-17 07:06:10 +00:00
}
void Output::writeDateTime( const DateTime& rDateTime )
{
writeDec( rDateTime.Year, 4, '0' );
writeChar( '-' );
writeDec( rDateTime.Month, 2, '0' );
writeChar( '-' );
writeDec( rDateTime.Day, 2, '0' );
writeChar( 'T' );
writeDec( rDateTime.Hours, 2, '0' );
writeChar( ':' );
writeDec( rDateTime.Minutes, 2, '0' );
writeChar( ':' );
writeDec( rDateTime.Seconds, 2, '0' );
}
void Output::writeColIndex( sal_Int32 nCol )
{
StringHelper::appendAddrCol( maLine, nCol, true );
}
void Output::writeRowIndex( sal_Int32 nRow )
{
StringHelper::appendAddrRow( maLine, nRow, true );
}
void Output::writeColRowRange( sal_Int32 nColRow1, sal_Int32 nColRow2 )
{
writeDec( nColRow1 );
writeChar( OOX_DUMP_RANGESEP );
writeDec( nColRow2 );
}
void Output::writeColRange( sal_Int32 nCol1, sal_Int32 nCol2 )
{
writeColIndex( nCol1 );
writeChar( OOX_DUMP_RANGESEP );
writeColIndex( nCol2 );
}
void Output::writeRowRange( sal_Int32 nRow1, sal_Int32 nRow2 )
{
writeRowIndex( nRow1 );
writeChar( OOX_DUMP_RANGESEP );
writeRowIndex( nRow2 );
}
void Output::writeAddress( const Address& rPos )
{
StringHelper::appendAddress( maLine, rPos );
}
void Output::writeRange( const Range& rRange )
{
StringHelper::appendRange( maLine, rRange );
}
void Output::writeRangeList( const RangeList& rRanges )
{
StringHelper::appendRangeList( maLine, rRanges );
}
// ----------------------------------------------------------------------------
void Output::construct( const Reference< XTextOutputStream >& rxStrm )
{
mxStrm = rxStrm;
mnCol = mnItemLevel = mnMultiLevel = 0;
mnItemIdx = 0;
mnLastItem = 0;
if( mxStrm.is() )
{
writeChar( OOX_DUMP_BOM );
newLine();
}
}
bool Output::implIsValid() const
{
return mxStrm.is();
}
2008-09-30 13:51:36 +00:00
void Output::writeItemName( const String& rItemName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
if( rItemName.has() && (rItemName[ 0 ] == '#') )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
writeString( rItemName.copy( 1 ) );
2008-01-17 07:06:10 +00:00
StringHelper::appendIndex( maLine, mnItemIdx++ );
}
else
2008-09-30 13:51:36 +00:00
writeString( rItemName );
}
// ============================================================================
StorageIterator::StorageIterator( const StorageRef& rxStrg ) :
mxStrg( rxStrg )
{
if( mxStrg.get() )
mxStrg->getElementNames( maNames );
maIt = maNames.begin();
}
StorageIterator::~StorageIterator()
{
}
size_t StorageIterator::getElementCount() const
{
return maNames.size();
}
StorageIterator& StorageIterator::operator++()
{
if( maIt != maNames.end() )
++maIt;
return *this;
}
OUString StorageIterator::getName() const
{
OUString aName;
if( maIt != maNames.end() )
aName = *maIt;
return aName;
}
bool StorageIterator::isStream() const
{
return isValid() && mxStrg->openInputStream( *maIt ).is();
}
bool StorageIterator::isStorage() const
{
if( !isValid() )
return false;
StorageRef xStrg = mxStrg->openSubStorage( *maIt, false );
return xStrg.get() && xStrg->isStorage();
}
bool StorageIterator::implIsValid() const
{
return mxStrg.get() && mxStrg->isStorage() && (maIt != maNames.end());
2008-01-17 07:06:10 +00:00
}
// ============================================================================
// ============================================================================
ObjectBase::~ObjectBase()
{
}
2008-09-30 13:51:36 +00:00
void ObjectBase::construct( const ConfigRef& rxConfig )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
mxConfig = rxConfig;
2008-01-17 07:06:10 +00:00
}
void ObjectBase::construct( const ObjectBase& rParent )
{
*this = rParent;
}
void ObjectBase::dump()
{
if( isValid() )
implDump();
}
bool ObjectBase::implIsValid() const
{
2008-09-30 13:51:36 +00:00
return isValid( mxConfig );
2008-01-17 07:06:10 +00:00
}
void ObjectBase::implDump()
{
}
2008-09-30 13:51:36 +00:00
void ObjectBase::reconstructConfig( const ConfigRef& rxConfig )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
if( isValid( rxConfig ) )
mxConfig = rxConfig;
2008-01-17 07:06:10 +00:00
}
// ============================================================================
// ============================================================================
2008-09-30 13:51:36 +00:00
void StorageObjectBase::construct( const ObjectBase& rParent, const StorageRef& rxStrg, const OUString& rSysPath )
2008-01-17 07:06:10 +00:00
{
ObjectBase::construct( rParent );
2008-09-30 13:51:36 +00:00
mxStrg = rxStrg;
maSysPath = rSysPath;
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void StorageObjectBase::construct( const ObjectBase& rParent )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ObjectBase::construct( rParent );
if( ObjectBase::implIsValid() )
{
mxStrg = cfg().getRootStorage();
maSysPath = cfg().getSysFileName();
}
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
bool StorageObjectBase::implIsValid() const
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
return mxStrg.get() && mxStrg->isStorage() && (maSysPath.getLength() > 0) && ObjectBase::implIsValid();
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void StorageObjectBase::implDump()
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
try
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
Reference< XSimpleFileAccess > xFileAccess( getFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW );
xFileAccess->kill( maSysPath + OOX_DUMP_DUMPEXT );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
catch( Exception& )
2008-01-17 07:06:10 +00:00
{
}
2008-09-30 13:51:36 +00:00
extractStorage( mxStrg, OUString(), maSysPath );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void StorageObjectBase::implDumpStream( const BinaryInputStreamRef&, const OUString&, const OUString&, const OUString& )
2008-01-17 07:06:10 +00:00
{
}
2008-09-30 13:51:36 +00:00
void StorageObjectBase::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
extractStorage( rxStrg, rStrgPath, rSysPath );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void StorageObjectBase::addPreferredStream( const String& rStrmName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
if( rStrmName.has() )
maPreferred.push_back( PreferredItem( rStrmName, false ) );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void StorageObjectBase::addPreferredStorage( const String& rStrgPath )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
if( rStrgPath.has() )
maPreferred.push_back( PreferredItem( rStrgPath, true ) );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
OUString StorageObjectBase::getSysFileName( const OUString& rStrmName, const OUString& rSysOutPath )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
// encode all characters < 0x20
OUStringBuffer aBuffer;
StringHelper::appendEncString( aBuffer, rStrmName, false );
// replace all characters reserved in file system
OUString aFileName = aBuffer.makeStringAndClear();
static const sal_Unicode spcReserved[] = { '/', '\\', ':', '*', '?', '<', '>', '|' };
for( const sal_Unicode* pcChar = spcReserved; pcChar < STATIC_ARRAY_END( spcReserved ); ++pcChar )
aFileName = aFileName.replace( *pcChar, '_' );
// build full path
return rSysOutPath + OUString( sal_Unicode( '/' ) ) + aFileName;
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void StorageObjectBase::extractStream( StorageBase& rStrg, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
BinaryXInputStream aInStrm( rStrg.openInputStream( rStrmName ), true );
if( !aInStrm.isEof() )
{
BinaryXOutputStream aOutStrm( InputOutputHelper::openOutputStream( getFactory(), rSysFileName ), true );
if( !aOutStrm.isEof() )
aOutStrm.copyStream( aInStrm );
}
BinaryXInputStreamRef xDumpStrm( new BinaryXInputStream( InputOutputHelper::openInputStream( getFactory(), rSysFileName ), true ) );
if( !xDumpStrm->isEof() )
implDumpStream( xDumpStrm, rStrgPath, rStrmName, rSysFileName );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void StorageObjectBase::extractStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
OUString aSysOutPath = rSysPath + OOX_DUMP_DUMPEXT;
// create directory in file system
::osl::FileBase::RC eRes = ::osl::Directory::create( aSysOutPath );
if( (eRes != ::osl::FileBase::E_None) && (eRes != ::osl::FileBase::E_EXIST) )
return;
// process preferred storages and streams in root storage first
if( rStrgPath.getLength() == 0 )
for( PreferredItemVector::iterator aIt = maPreferred.begin(), aEnd = maPreferred.end(); aIt != aEnd; ++aIt )
extractItem( rxStrg, rStrgPath, aIt->maName, aSysOutPath, aIt->mbStorage, !aIt->mbStorage );
// process children of the storage
for( StorageIterator aIt( rxStrg ); aIt.isValid(); ++aIt )
{
// skip processed preferred items
OUString aItemName = aIt.getName();
bool bFound = false;
if( rStrgPath.getLength() == 0 )
for( PreferredItemVector::iterator aIIt = maPreferred.begin(), aIEnd = maPreferred.end(); !bFound && (aIIt != aIEnd); ++aIIt )
bFound = aIIt->maName == aItemName;
if( !bFound )
extractItem( rxStrg, rStrgPath, aItemName, aSysOutPath, aIt.isStorage(), aIt.isStream() );
}
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void StorageObjectBase::extractItem( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rItemName, const OUString& rSysOutPath, bool bIsStrg, bool bIsStrm )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
OUString aSysFileName = getSysFileName( rItemName, rSysOutPath );
if( bIsStrg )
{
OUStringBuffer aStrgPath( rStrgPath );
StringHelper::appendToken( aStrgPath, rItemName, '/' );
implDumpStorage( rxStrg->openSubStorage( rItemName, false ), aStrgPath.makeStringAndClear(), aSysFileName );
}
else if( bIsStrm )
{
extractStream( *rxStrg, rStrgPath, rItemName, aSysFileName );
}
2008-01-17 07:06:10 +00:00
}
// ============================================================================
// ============================================================================
OutputObjectBase::~OutputObjectBase()
{
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::construct( const ObjectBase& rParent, const OUString& rSysFileName )
2008-01-17 07:06:10 +00:00
{
ObjectBase::construct( rParent );
2008-09-30 13:51:36 +00:00
if( ObjectBase::implIsValid() )
mxOut.reset( new Output( getFactory(), rSysFileName + OOX_DUMP_DUMPEXT ) );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::construct( const ObjectBase& rParent, const OutputRef& rxOut )
2008-01-17 07:06:10 +00:00
{
ObjectBase::construct( rParent );
2008-09-30 13:51:36 +00:00
mxOut = rxOut;
2008-01-17 07:06:10 +00:00
}
void OutputObjectBase::construct( const OutputObjectBase& rParent )
{
*this = rParent;
}
bool OutputObjectBase::implIsValid() const
{
return isValid( mxOut ) && ObjectBase::implIsValid();
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeEmptyItem( const String& rName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( *mxOut, rName );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeInfoItem( const String& rName, const String& rData )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( *mxOut, rName );
mxOut->writeString( rData );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeCharItem( const String& rName, sal_Unicode cData )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( *mxOut, rName );
mxOut->writeChar( OOX_DUMP_STRQUOTE );
mxOut->writeChar( cData );
mxOut->writeChar( OOX_DUMP_STRQUOTE );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeStringItem( const String& rName, const OUString& rData )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( *mxOut, rName );
2008-01-17 07:06:10 +00:00
mxOut->writeAscii( "(len=" );
mxOut->writeDec( rData.getLength() );
mxOut->writeAscii( ")," );
OUStringBuffer aValue( rData.copy( 0, ::std::min( rData.getLength(), OOX_DUMP_MAXSTRLEN ) ) );
StringHelper::enclose( aValue, OOX_DUMP_STRQUOTE );
mxOut->writeString( aValue.makeStringAndClear() );
if( rData.getLength() > OOX_DUMP_MAXSTRLEN )
mxOut->writeAscii( ",cut" );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeArrayItem( const String& rName, const sal_uInt8* pnData, sal_Size nSize, sal_Unicode cSep )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( *mxOut, rName );
2008-01-17 07:06:10 +00:00
mxOut->writeArray( pnData, nSize, cSep );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeBoolItem( const String& rName, bool bData )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( *mxOut, rName );
2008-01-17 07:06:10 +00:00
mxOut->writeBool( bData );
}
2008-09-30 13:51:36 +00:00
double OutputObjectBase::writeRkItem( const String& rName, sal_Int32 nRk )
2008-01-17 07:06:10 +00:00
{
MultiItemsGuard aMultiGuard( out() );
2008-09-30 13:51:36 +00:00
writeHexItem( rName, static_cast< sal_uInt32 >( nRk ), "RK-FLAGS" );
2008-01-17 07:06:10 +00:00
double fValue = ::oox::xls::BiffHelper::calcDoubleFromRk( nRk );
writeDecItem( "decoded", fValue );
return fValue;
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeColorABGRItem( const String& rName, sal_Int32 nColor )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( *mxOut, rName );
writeHexItem( rName, nColor );
mxOut->writeColorABGR( nColor );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeDateTimeItem( const String& rName, const DateTime& rDateTime )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( *mxOut, rName );
2008-01-17 07:06:10 +00:00
mxOut->writeDateTime( rDateTime );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeGuidItem( const String& rName, const OUString& rGuid )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( *mxOut, rName );
2008-01-17 07:06:10 +00:00
mxOut->writeString( rGuid );
aItem.cont();
mxOut->writeString( cfg().getStringOption( rGuid, OUString() ) );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeColIndexItem( const String& rName, sal_Int32 nCol )
2008-01-17 07:06:10 +00:00
{
Output& rOut = out();
2008-09-30 13:51:36 +00:00
ItemGuard aItem( rOut, rName );
2008-01-17 07:06:10 +00:00
rOut.writeDec( nCol );
aItem.cont();
rOut.writeColIndex( nCol );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeRowIndexItem( const String& rName, sal_Int32 nRow )
2008-01-17 07:06:10 +00:00
{
Output& rOut = out();
2008-09-30 13:51:36 +00:00
ItemGuard aItem( rOut, rName );
2008-01-17 07:06:10 +00:00
rOut.writeDec( nRow );
aItem.cont();
rOut.writeRowIndex( nRow );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeColRangeItem( const String& rName, sal_Int32 nCol1, sal_Int32 nCol2 )
2008-01-17 07:06:10 +00:00
{
Output& rOut = out();
2008-09-30 13:51:36 +00:00
ItemGuard aItem( rOut, rName );
2008-01-17 07:06:10 +00:00
rOut.writeColRowRange( nCol1, nCol2 );
aItem.cont();
rOut.writeColRange( nCol1, nCol2 );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeRowRangeItem( const String& rName, sal_Int32 nRow1, sal_Int32 nRow2 )
2008-01-17 07:06:10 +00:00
{
Output& rOut = out();
2008-09-30 13:51:36 +00:00
ItemGuard aItem( rOut, rName );
2008-01-17 07:06:10 +00:00
rOut.writeColRowRange( nRow1, nRow2 );
aItem.cont();
rOut.writeRowRange( nRow1, nRow2 );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeAddressItem( const String& rName, const Address& rPos )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( out(), rName );
2008-01-17 07:06:10 +00:00
StringHelper::appendAddress( out().getLine(), rPos );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeRangeItem( const String& rName, const Range& rRange )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( out(), rName );
2008-01-17 07:06:10 +00:00
StringHelper::appendRange( out().getLine(), rRange );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeRangeListItem( const String& rName, const RangeList& rRanges )
2008-01-17 07:06:10 +00:00
{
MultiItemsGuard aMultiGuard( out() );
2008-09-30 13:51:36 +00:00
writeEmptyItem( rName );
2008-01-17 07:06:10 +00:00
writeDecItem( "count", static_cast< sal_uInt16 >( rRanges.size() ) );
ItemGuard aItem( out(), "ranges" );
StringHelper::appendRangeList( out().getLine(), rRanges );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeTokenAddressItem( const String& rName, const TokenAddress& rPos, bool bNameMode )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( out(), rName );
2008-01-17 07:06:10 +00:00
StringHelper::appendAddress( out().getLine(), rPos, bNameMode );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeTokenAddress3dItem( const String& rName, const OUString& rRef, const TokenAddress& rPos, bool bNameMode )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( out(), rName );
2008-01-17 07:06:10 +00:00
out().writeString( rRef );
StringHelper::appendAddress( out().getLine(), rPos, bNameMode );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeTokenRangeItem( const String& rName, const TokenRange& rRange, bool bNameMode )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( out(), rName );
2008-01-17 07:06:10 +00:00
StringHelper::appendRange( out().getLine(), rRange, bNameMode );
}
2008-09-30 13:51:36 +00:00
void OutputObjectBase::writeTokenRange3dItem( const String& rName, const OUString& rRef, const TokenRange& rRange, bool bNameMode )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
ItemGuard aItem( out(), rName );
2008-01-17 07:06:10 +00:00
out().writeString( rRef );
StringHelper::appendRange( out().getLine(), rRange, bNameMode );
}
// ============================================================================
// ============================================================================
InputObjectBase::~InputObjectBase()
{
}
2008-09-30 13:51:36 +00:00
void InputObjectBase::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
OutputObjectBase::construct( rParent, rSysFileName );
mxStrm = rxStrm;
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void InputObjectBase::construct( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OutputRef& rxOut )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
OutputObjectBase::construct( rParent, rxOut );
mxStrm = rxStrm;
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void InputObjectBase::construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm )
2008-01-17 07:06:10 +00:00
{
OutputObjectBase::construct( rParent );
2008-09-30 13:51:36 +00:00
mxStrm = rxStrm;
2008-01-17 07:06:10 +00:00
}
void InputObjectBase::construct( const InputObjectBase& rParent )
{
*this = rParent;
}
bool InputObjectBase::implIsValid() const
{
2008-09-30 13:51:36 +00:00
return mxStrm.get() && OutputObjectBase::implIsValid();
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void InputObjectBase::skipBlock( sal_Int64 nBytes, bool bShowSize )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
sal_Int64 nEndPos = ::std::min< sal_Int64 >( mxStrm->tell() + nBytes, mxStrm->getLength() );
if( mxStrm->tell() < nEndPos )
2008-01-17 07:06:10 +00:00
{
if( bShowSize )
2008-09-30 13:51:36 +00:00
writeDecItem( "skipped-data-size", static_cast< sal_uInt64 >( nEndPos - mxStrm->tell() ) );
mxStrm->seek( nEndPos );
2008-01-17 07:06:10 +00:00
}
}
2008-09-30 13:51:36 +00:00
void InputObjectBase::dumpRawBinary( sal_Int64 nBytes, bool bShowOffset, bool bStream )
2008-01-17 07:06:10 +00:00
{
Output& rOut = out();
TableGuard aTabGuard( rOut,
bShowOffset ? 12 : 0,
3 * OOX_DUMP_BYTESPERLINE / 2 + 1,
3 * OOX_DUMP_BYTESPERLINE / 2 + 1,
OOX_DUMP_BYTESPERLINE / 2 + 1 );
2008-09-30 13:51:36 +00:00
sal_Int64 nMaxShowSize = cfg().getIntOption< sal_Int64 >(
bStream ? "max-binary-stream-size" : "max-binary-data-size", SAL_MAX_INT64 );
2008-01-17 07:06:10 +00:00
2008-09-30 13:51:36 +00:00
bool bSeekable = mxStrm->getLength() >= 0;
sal_Int64 nEndPos = bSeekable ? ::std::min< sal_Int64 >( mxStrm->tell() + nBytes, mxStrm->getLength() ) : 0;
sal_Int64 nDumpEnd = bSeekable ? ::std::min< sal_Int64 >( mxStrm->tell() + nMaxShowSize, nEndPos ) : nMaxShowSize;
sal_Int64 nPos = bSeekable ? mxStrm->tell() : 0;
2008-01-17 07:06:10 +00:00
bool bLoop = true;
while( bLoop && (nPos < nDumpEnd) )
{
rOut.writeHex( static_cast< sal_uInt32 >( nPos ) );
rOut.tab();
sal_uInt8 pnLineData[ OOX_DUMP_BYTESPERLINE ];
2008-09-30 13:51:36 +00:00
sal_Int32 nLineSize = bSeekable ? ::std::min( static_cast< sal_Int32 >( nDumpEnd - mxStrm->tell() ), OOX_DUMP_BYTESPERLINE ) : OOX_DUMP_BYTESPERLINE;
sal_Int32 nReadSize = mxStrm->readMemory( pnLineData, nLineSize );
2008-01-17 07:06:10 +00:00
bLoop = nReadSize == nLineSize;
nPos += nReadSize;
if( nReadSize > 0 )
{
const sal_uInt8* pnByte = 0;
const sal_uInt8* pnEnd = 0;
for( pnByte = pnLineData, pnEnd = pnLineData + nReadSize; pnByte != pnEnd; ++pnByte )
{
if( (pnByte - pnLineData) == (OOX_DUMP_BYTESPERLINE / 2) ) rOut.tab();
rOut.writeHex( *pnByte, false );
rOut.writeChar( ' ' );
}
aTabGuard.tab( 3 );
2008-09-30 13:51:36 +00:00
for( pnByte = pnLineData, pnEnd = pnLineData + nReadSize; pnByte != pnEnd; ++pnByte )
2008-01-17 07:06:10 +00:00
{
if( (pnByte - pnLineData) == (OOX_DUMP_BYTESPERLINE / 2) ) rOut.tab();
rOut.writeChar( static_cast< sal_Unicode >( (*pnByte < 0x20) ? '.' : *pnByte ) );
}
rOut.newLine();
}
}
// skip undumped data
if( bSeekable )
2008-09-30 13:51:36 +00:00
skipBlock( nEndPos - mxStrm->tell() );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void InputObjectBase::dumpBinary( const String& rName, sal_Int64 nBytes, bool bShowOffset )
2008-01-17 07:06:10 +00:00
{
{
MultiItemsGuard aMultiGuard( out() );
2008-09-30 13:51:36 +00:00
writeEmptyItem( rName );
2008-01-17 07:06:10 +00:00
writeDecItem( "size", nBytes );
}
IndentGuard aIndGuard( out() );
dumpRawBinary( nBytes, bShowOffset );
}
2008-09-30 13:51:36 +00:00
void InputObjectBase::dumpRemaining( sal_Int64 nBytes )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
if( nBytes > 0 )
{
if( cfg().getBoolOption( "show-trailing-unknown", true ) )
dumpBinary( "remaining-data", nBytes, false );
else
skipBlock( nBytes );
}
}
void InputObjectBase::dumpRemainingTo( sal_Int64 nPos )
{
if( mxStrm->isEof() )
writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM );
else
dumpRemaining( nPos - mxStrm->tell() );
mxStrm->seek( nPos );
}
void InputObjectBase::dumpRemainingStream()
{
dumpRemainingTo( mxStrm->getLength() );
}
void InputObjectBase::dumpArray( const String& rName, sal_Int32 nBytes, sal_Unicode cSep )
{
sal_Int32 nDumpSize = getLimitedValue< sal_Int32, sal_Int64 >( mxStrm->getLength() - mxStrm->tell(), 0, nBytes );
2008-01-17 07:06:10 +00:00
if( nDumpSize > OOX_DUMP_MAXARRAY )
{
2008-09-30 13:51:36 +00:00
dumpBinary( rName, nBytes, false );
2008-01-17 07:06:10 +00:00
}
else if( nDumpSize > 1 )
{
sal_uInt8 pnData[ OOX_DUMP_MAXARRAY ];
2008-09-30 13:51:36 +00:00
mxStrm->readMemory( pnData, nDumpSize );
writeArrayItem( rName, pnData, nDumpSize, cSep );
2008-01-17 07:06:10 +00:00
}
else if( nDumpSize == 1 )
2008-09-30 13:51:36 +00:00
dumpHex< sal_uInt8 >( rName );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
sal_Unicode InputObjectBase::dumpChar( const String& rName, rtl_TextEncoding eTextEnc )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
sal_uInt8 nChar;
*mxStrm >> nChar;
OUString aChar = OStringToOUString( OString( static_cast< sal_Char >( nChar ) ), eTextEnc );
sal_Unicode cChar = (aChar.getLength() > 0) ? aChar[ 0 ] : 0;
writeCharItem( rName( "char" ), cChar );
return cChar;
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
sal_Unicode InputObjectBase::dumpUnicode( const String& rName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
sal_uInt16 nChar;
*mxStrm >> nChar;
sal_Unicode cChar = static_cast< sal_Unicode >( nChar );
writeCharItem( rName( "char" ), cChar );
return cChar;
}
OUString InputObjectBase::dumpCharArray( const String& rName, sal_Int32 nLen, rtl_TextEncoding eTextEnc )
{
sal_Int32 nDumpSize = getLimitedValue< sal_Int32, sal_Int64 >( mxStrm->getLength() - mxStrm->tell(), 0, nLen );
2008-01-17 07:06:10 +00:00
OUString aString;
if( nDumpSize > 0 )
{
2008-09-30 13:51:36 +00:00
::std::vector< sal_Char > aBuffer( static_cast< sal_Size >( nLen ) + 1 );
sal_Int32 nCharsRead = mxStrm->readMemory( &aBuffer.front(), nLen );
2008-01-17 07:06:10 +00:00
aBuffer[ nCharsRead ] = 0;
aString = OStringToOUString( OString( &aBuffer.front() ), eTextEnc );
}
2008-09-30 13:51:36 +00:00
writeStringItem( rName( "text" ), aString );
2008-01-17 07:06:10 +00:00
return aString;
}
2008-09-30 13:51:36 +00:00
OUString InputObjectBase::dumpUnicodeArray( const String& rName, sal_Int32 nLen )
2008-01-17 07:06:10 +00:00
{
OUStringBuffer aBuffer;
2008-09-30 13:51:36 +00:00
for( sal_Int32 nIndex = 0; !mxStrm->isEof() && (nIndex < nLen); ++nIndex )
aBuffer.append( static_cast< sal_Unicode >( mxStrm->readuInt16() ) );
2008-01-17 07:06:10 +00:00
OUString aString = aBuffer.makeStringAndClear();
2008-09-30 13:51:36 +00:00
writeStringItem( rName( "text" ), aString );
2008-01-17 07:06:10 +00:00
return aString;
}
2008-09-30 13:51:36 +00:00
OUString InputObjectBase::dumpNullCharArray( const String& rName, rtl_TextEncoding eTextEnc )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
OStringBuffer aBuffer;
sal_uInt8 nChar;
for( *mxStrm >> nChar; !mxStrm->isEof() && (nChar > 0); *mxStrm >> nChar )
aBuffer.append( static_cast< sal_Char >( nChar ) );
OUString aString = OStringToOUString( aBuffer.makeStringAndClear(), eTextEnc );
writeStringItem( rName( "text" ), aString );
return aString;
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
OUString InputObjectBase::dumpNullUnicodeArray( const String& rName )
{
OUStringBuffer aBuffer;
sal_uInt16 nChar;
for( *mxStrm >> nChar; !mxStrm->isEof() && (nChar > 0); *mxStrm >> nChar )
aBuffer.append( static_cast< sal_Unicode >( nChar ) );
OUString aString = aBuffer.makeStringAndClear();
writeStringItem( rName( "text" ), aString );
return aString;
}
double InputObjectBase::dumpRk( const String& rName )
{
sal_Int32 nRk;
*mxStrm >> nRk;
return writeRkItem( rName( "rk-value" ), nRk );
}
sal_Int32 InputObjectBase::dumpColorABGR( const String& rName )
{
sal_Int32 nColor;
*mxStrm >> nColor;
writeColorABGRItem( rName( "color" ), nColor );
return nColor;
}
DateTime InputObjectBase::dumpFileTime( const String& rName )
{
DateTime aDateTime;
ItemGuard aItem( out(), rName( "file-time" ) );
sal_Int64 nFileTime = dumpDec< sal_Int64 >( EMPTY_STRING );
// file time is in 10^-7 seconds (100 nanoseconds), convert to 1/100 seconds
nFileTime /= 100000;
// entire days
sal_Int64 nDays = nFileTime / sal_Int64( 360000 * 24 );
// number of entire years
sal_Int64 nYears = (nDays - (nDays / (4 * 365)) + (nDays / (100 * 365)) - (nDays / (400 * 365))) / 365;
// remaining days in the year
sal_Int64 nDaysInYear = nDays - (nYears * 365 + nYears / 4 - nYears / 100 + nYears / 400);
// the year (file dates start from 1601-01-01)
aDateTime.Year = static_cast< sal_uInt16 >( 1601 + nYears );
// leap year?
bool bLeap = ((aDateTime.Year % 4 == 0) && (aDateTime.Year % 100 != 0)) || (aDateTime.Year % 400 == 0);
// static arrays with number of days in month
static const sal_Int64 spnDaysInMonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
static const sal_Int64 spnDaysInMonthL[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
const sal_Int64* pnDaysInMonth = bLeap ? spnDaysInMonthL : spnDaysInMonth;
// the month
aDateTime.Month = 1;
while( nDaysInYear >= *pnDaysInMonth )
{
nDaysInYear -= *pnDaysInMonth++;
++aDateTime.Month;
}
// the day
aDateTime.Day = static_cast< sal_uInt16 >( nDaysInYear + 1 );
// number of 1/100 seconds in the day
sal_Int64 nTimeInDay = nFileTime % sal_Int64( 360000 * 24 );
// 1/100 seconds
aDateTime.HundredthSeconds = static_cast< sal_uInt16 >( nTimeInDay % 100 );
nTimeInDay /= 100;
// seconds
aDateTime.Seconds = static_cast< sal_uInt16 >( nTimeInDay % 60 );
nTimeInDay /= 60;
// minutes
aDateTime.Minutes = static_cast< sal_uInt16 >( nTimeInDay % 60 );
nTimeInDay /= 60;
// hours
aDateTime.Hours = static_cast< sal_uInt16 >( nTimeInDay );
writeDateTimeItem( EMPTY_STRING, aDateTime );
return aDateTime;
}
OUString InputObjectBase::dumpGuid( const String& rName )
2008-01-17 07:06:10 +00:00
{
OUStringBuffer aBuffer;
sal_uInt32 nData32;
sal_uInt16 nData16;
sal_uInt8 nData8;
2008-09-30 13:51:36 +00:00
*mxStrm >> nData32;
2008-01-17 07:06:10 +00:00
StringHelper::appendHex( aBuffer, nData32, false );
aBuffer.append( sal_Unicode( '-' ) );
2008-09-30 13:51:36 +00:00
*mxStrm >> nData16;
2008-01-17 07:06:10 +00:00
StringHelper::appendHex( aBuffer, nData16, false );
aBuffer.append( sal_Unicode( '-' ) );
2008-09-30 13:51:36 +00:00
*mxStrm >> nData16;
2008-01-17 07:06:10 +00:00
StringHelper::appendHex( aBuffer, nData16, false );
aBuffer.append( sal_Unicode( '-' ) );
2008-09-30 13:51:36 +00:00
*mxStrm >> nData8;
2008-01-17 07:06:10 +00:00
StringHelper::appendHex( aBuffer, nData8, false );
2008-09-30 13:51:36 +00:00
*mxStrm >> nData8;
2008-01-17 07:06:10 +00:00
StringHelper::appendHex( aBuffer, nData8, false );
aBuffer.append( sal_Unicode( '-' ) );
for( int nIndex = 0; nIndex < 6; ++nIndex )
{
2008-09-30 13:51:36 +00:00
*mxStrm >> nData8;
2008-01-17 07:06:10 +00:00
StringHelper::appendHex( aBuffer, nData8, false );
}
2008-09-30 13:51:36 +00:00
StringHelper::enclose( aBuffer, '{', '}' );
2008-01-17 07:06:10 +00:00
OUString aGuid = aBuffer.makeStringAndClear();
2008-09-30 13:51:36 +00:00
writeGuidItem( rName( "guid" ), aGuid );
2008-01-17 07:06:10 +00:00
return aGuid;
}
void InputObjectBase::dumpItem( const ItemFormat& rItemFmt )
{
switch( rItemFmt.meDataType )
{
case DATATYPE_VOID: break;
case DATATYPE_INT8: dumpValue< sal_Int8 >( rItemFmt ); break;
case DATATYPE_UINT8: dumpValue< sal_uInt8 >( rItemFmt ); break;
case DATATYPE_INT16: dumpValue< sal_Int16 >( rItemFmt ); break;
case DATATYPE_UINT16: dumpValue< sal_uInt16 >( rItemFmt ); break;
case DATATYPE_INT32: dumpValue< sal_Int32 >( rItemFmt ); break;
case DATATYPE_UINT32: dumpValue< sal_uInt32 >( rItemFmt ); break;
case DATATYPE_INT64: dumpValue< sal_Int64 >( rItemFmt ); break;
case DATATYPE_UINT64: dumpValue< sal_uInt64 >( rItemFmt ); break;
case DATATYPE_FLOAT: dumpValue< float >( rItemFmt ); break;
case DATATYPE_DOUBLE: dumpValue< double >( rItemFmt ); break;
default:;
}
}
2008-09-30 13:51:36 +00:00
// ============================================================================
2008-01-17 07:06:10 +00:00
// ============================================================================
2008-09-30 13:51:36 +00:00
BinaryStreamObject::BinaryStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
InputObjectBase::construct( rParent, rxStrm, rSysFileName );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
BinaryStreamObject::BinaryStreamObject( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxStrm )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
InputObjectBase::construct( rParent, rxStrm );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void BinaryStreamObject::dumpBinaryStream( bool bShowOffset )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
in().seek( 0 );
dumpRawBinary( in().getLength(), bShowOffset, true );
out().emptyLine();
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void BinaryStreamObject::implDump()
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
dumpBinaryStream();
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
// ============================================================================
namespace {
bool lclIsEof( BinaryInputStream& rStrm )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
return rStrm.isEof() || (rStrm.isSeekable() && (rStrm.tell() >= rStrm.getLength()));
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
template< typename BufferType, typename CharType >
CharType lclAppendChar( BufferType& orBuffer, CharType cChar )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
if( (cChar == 0x0A) || (cChar == 0x0D) )
return cChar;
orBuffer.append( cChar );
return 0;
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
template< typename BufferType, typename CharType, typename StreamDataType >
bool lclReadLine( BufferType& orBuffer, sal_Unicode& orcNextLineChar, BinaryInputStream& rStrm )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
CharType cLineEndChar = (orcNextLineChar == 0) ? 0 : lclAppendChar( orBuffer, static_cast< CharType >( orcNextLineChar ) );
orcNextLineChar = 0;
// read chars until EOF or line end character (LF or CR)
bool bIsEof = lclIsEof( rStrm );
while( !bIsEof && (cLineEndChar == 0) )
{
CharType cChar = static_cast< CharType >( rStrm.readValue< StreamDataType >() );
bIsEof = rStrm.isEof();
cLineEndChar = bIsEof ? 0 : lclAppendChar( orBuffer, cChar );
}
// try to skip LF following CR, or CR following LF
if( !lclIsEof( rStrm ) && (cLineEndChar != 0) )
{
CharType cChar = static_cast< CharType >( rStrm.readValue< StreamDataType >() );
bool bLineEnd = ((cChar == 0x0A) || (cChar == 0x0D)) && (cChar != cLineEndChar);
if( !rStrm.isEof() && !bLineEnd )
orcNextLineChar = static_cast< sal_Unicode >( cChar );
}
return (cLineEndChar != 0) || (orBuffer.getLength() > 0);
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
} // namespace
// ----------------------------------------------------------------------------
2008-01-17 07:06:10 +00:00
TextStreamObject::TextStreamObject( const ObjectBase& rParent,
2008-09-30 13:51:36 +00:00
const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc, const OUString& rSysFileName ) :
meTextEnc( eTextEnc )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
InputObjectBase::construct( rParent, rxStrm, rSysFileName );
}
TextStreamObject::TextStreamObject( const OutputObjectBase& rParent,
const BinaryInputStreamRef& rxStrm, rtl_TextEncoding eTextEnc ) :
meTextEnc( eTextEnc )
{
InputObjectBase::construct( rParent, rxStrm );
2008-01-17 07:06:10 +00:00
}
void TextStreamObject::implDump()
{
2008-09-30 13:51:36 +00:00
OUString aLine;
sal_Unicode cNextLineChar = 0;
sal_uInt32 nLine = 0;
while( readLine( aLine, cNextLineChar ) )
implDumpLine( aLine, ++nLine );
out().emptyLine();
2008-01-17 07:06:10 +00:00
}
void TextStreamObject::implDumpLine( const OUString& rLine, sal_uInt32 nLine )
2008-01-17 07:06:10 +00:00
{
Output& rOut = out();
TableGuard aTabGuard( rOut, 8 );
rOut.writeDec( nLine, 6 );
rOut.tab();
rOut.writeString( rLine );
rOut.newLine();
}
2008-01-17 07:06:10 +00:00
2008-09-30 13:51:36 +00:00
bool TextStreamObject::readCharLine( OUString& orLine, sal_Unicode& orcNextLineChar )
{
OStringBuffer aBuffer;
bool bHasData = lclReadLine< OStringBuffer, sal_Char, sal_uInt8 >( aBuffer, orcNextLineChar, in() );
if( bHasData )
orLine = OStringToOUString( aBuffer.makeStringAndClear(), meTextEnc );
return bHasData;
}
bool TextStreamObject::readUcs2Line( OUString& orLine, sal_Unicode& orcNextLineChar )
{
OUStringBuffer aBuffer;
bool bHasData = lclReadLine< OUStringBuffer, sal_Unicode, sal_uInt16 >( aBuffer, orcNextLineChar, in() );
if( bHasData )
orLine = aBuffer.makeStringAndClear();
return bHasData;
}
bool TextStreamObject::readLine( OUString& orLine, sal_Unicode& orcNextLineChar )
{
return (meTextEnc == RTL_TEXTENCODING_UCS2) ?
readUcs2Line( orLine, orcNextLineChar ) :
readCharLine( orLine, orcNextLineChar );
}
// ============================================================================
2008-09-30 13:51:36 +00:00
XmlStreamObject::XmlStreamObject( const ObjectBase& rParent, const BinaryInputStreamRef& rxStrm, const OUString& rSysFileName ) :
TextStreamObject( rParent, rxStrm, RTL_TEXTENCODING_UTF8, rSysFileName )
{
}
void XmlStreamObject::implDump()
{
maIncompleteLine = OUString();
TextStreamObject::implDump();
if( maIncompleteLine.getLength() > 0 )
2008-01-17 07:06:10 +00:00
{
out().resetIndent();
out().writeString( maIncompleteLine );
out().emptyLine();
writeInfoItem( "stream-state", OOX_DUMP_ERR_STREAM );
}
}
void XmlStreamObject::implDumpLine( const OUString& rLine, sal_uInt32 )
{
// build input line from cached incomplete element and new text data
OUStringBuffer aLine;
if( maIncompleteLine.getLength() > 0 )
aLine.append( maIncompleteLine ).append( sal_Unicode( ' ' ) );
aLine.append( rLine );
maIncompleteLine = OUString();
Output& rOut = out();
if( aLine.getLength() == 0 )
{
rOut.newLine();
return;
}
const sal_Unicode* pcPos = aLine.getStr();
const sal_Unicode* pcEnd = pcPos + aLine.getLength();
while( pcPos < pcEnd )
{
OUStringBuffer aOutLine;
bool bIsStartElement = false;
bool bIsComplElement = false;
bool bIsEndElement = false;
/* check for start element at beginning of the line - pcEnd and thus (pcPos+1)
are dereferenceable, because OUStringBuffer::getStr is null-terminated. */
if( (*pcPos == '<') && (*(pcPos + 1) != '/') )
{
const sal_Unicode* pcElementEnd = ::std::find( pcPos, pcEnd, '>' );
if( pcElementEnd == pcEnd )
{
// incomplete start element
maIncompleteLine = OUString( pcPos, static_cast< sal_Int32 >( pcEnd - pcPos ) );
pcPos = pcEnd;
}
else
{
bIsComplElement = (*(pcPos + 1) == '?') || (*(pcElementEnd - 1) == '/');
bIsStartElement = !bIsComplElement;
++pcElementEnd;
aOutLine.append( pcPos, static_cast< sal_Int32 >( pcElementEnd - pcPos ) );
pcPos = pcElementEnd;
}
}
// check for following element text
if( !bIsComplElement && (pcPos < pcEnd) )
{
const sal_Unicode* pcElementStart = ::std::find( pcPos, pcEnd, '<' );
// append text between elements
if( pcPos < pcElementStart )
{
OUString aText( pcPos, static_cast< sal_Int32 >( pcElementStart - pcPos ) );
if( aText.trim().getLength() > 0 )
aOutLine.append( aText );
pcPos = pcElementStart;
}
}
// check for stand-alone or following end element
if( !bIsComplElement && (pcPos < pcEnd) && (*(pcPos + 1) == '/') )
{
const sal_Unicode* pcElementEnd = ::std::find( pcPos, pcEnd, '>' );
if( pcElementEnd == pcEnd )
{
// incomplete end element
aOutLine.append( pcPos, static_cast< sal_Int32 >( pcEnd - pcPos ) );
maIncompleteLine = aOutLine.makeStringAndClear();
pcPos = pcEnd;
}
else
{
bIsEndElement = true;
++pcElementEnd;
aOutLine.append( pcPos, static_cast< sal_Int32 >( pcElementEnd - pcPos ) );
pcPos = pcElementEnd;
}
}
// flush output line
if( maIncompleteLine.getLength() == 0 )
2008-01-17 07:06:10 +00:00
{
if( !bIsStartElement && bIsEndElement ) rOut.decIndent();
rOut.writeString( aOutLine.makeStringAndClear() );
2008-01-17 07:06:10 +00:00
rOut.newLine();
if( bIsStartElement && !bIsEndElement ) rOut.incIndent();
2008-01-17 07:06:10 +00:00
}
}
}
// ============================================================================
// ============================================================================
2008-09-30 13:51:36 +00:00
void RecordObjectBase::construct( const ObjectBase& rParent,
const BinaryInputStreamRef& rxBaseStrm, const OUString& rSysFileName,
const BinaryInputStreamRef& rxRecStrm, const String& rRecNames, const String& rSimpleRecs )
{
InputObjectBase::construct( rParent, rxRecStrm, rSysFileName );
constructRecObjBase( rxBaseStrm, rRecNames, rSimpleRecs );
}
void RecordObjectBase::construct( const OutputObjectBase& rParent, const BinaryInputStreamRef& rxBaseStrm,
const BinaryInputStreamRef& rxRecStrm, const String& rRecNames, const String& rSimpleRecs )
{
InputObjectBase::construct( rParent, rxRecStrm );
constructRecObjBase( rxBaseStrm, rRecNames, rSimpleRecs );
}
bool RecordObjectBase::implIsValid() const
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
return mxBaseStrm.get() && InputObjectBase::implIsValid();
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void RecordObjectBase::implDump()
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
NameListRef xRecNames = getRecNames();
typedef ::std::map< sal_Int64, ItemFormat > ItemFormatMap;
ItemFormatMap aSimpleRecs;
if( NameListBase* pSimpleRecs = maSimpleRecs.getNameList( cfg() ).get() )
for( NameListBase::const_iterator aIt = pSimpleRecs->begin(), aEnd = pSimpleRecs->end(); aIt != aEnd; ++aIt )
aSimpleRecs[ aIt->first ].parse( aIt->second );
while( implStartRecord( *mxBaseStrm, mnRecPos, mnRecId, mnRecSize ) )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
// record header
out().emptyLine();
writeHeader();
implWriteExtHeader();
IndentGuard aIndGuard( out() );
sal_Int64 nRecPos = in().tell();
// record body
if( cfg().hasName( xRecNames, mnRecId ) )
{
ItemFormatMap::const_iterator aIt = aSimpleRecs.find( mnRecId );
if( aIt != aSimpleRecs.end() )
dumpItem( aIt->second );
else
implDumpRecordBody();
}
// remaining undumped data
CWS-TOOLING: integrate CWS dr67 2009-04-08 13:23:56 +0200 dr r270638 : #i100534# reverted 2009-04-08 10:14:55 +0200 dr r270621 : CWS-TOOLING: rebase CWS dr67 to trunk@270033 (milestone: DEV300:m45) 2009-04-07 21:06:33 +0200 dr r270610 : #i100534# sc does not link in debug mode 2009-03-12 11:20:09 +0100 dr r269375 : #i10000# wae 2009-03-11 19:43:55 +0100 dr r269351 : #i10000# adjust oox namespace ids according to oox/inc/oox/core/namespaces.hxx 2009-03-11 15:38:52 +0100 dr r269339 : CWS-TOOLING: rebase CWS dr67 to trunk@269297 (milestone: DEV300:m43) 2009-02-27 15:20:21 +0100 dr r268598 : CWS-TOOLING: rebase CWS dr67 to trunk@268395 (milestone: DEV300:m42) 2009-02-19 13:32:17 +0100 dr r268277 : moved hf parser into page settings 2009-02-19 12:25:15 +0100 dr r268272 : renamed some structs according to chart filter 2009-02-16 15:51:31 +0100 dr r267823 : #i97873# import autosort settings from BIFF8/OOBIN/OOXML 2009-02-06 17:09:29 +0100 dr r267477 : #i97873# minor changes 2009-02-06 16:38:56 +0100 dr r267473 : #i97873# import date grouping settings from BIFF5/BIFF8/OOBIN/OOXML 2009-02-06 16:38:11 +0100 dr r267472 : #i97873# check min/max/step of passed GroupInfo 2009-02-06 16:35:13 +0100 dr r267471 : #i97873# more doc for createDategroup() 2009-02-06 13:53:42 +0100 dr r267459 : #i97873# make XDataPilotGrouping::createDateGroup() implementation working and robust against wrong input data 2009-02-06 13:52:16 +0100 dr r267458 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-06 12:35:49 +0100 dr r267453 : fix other IDLC warnings in sheet module 2009-02-06 12:05:19 +0100 dr r267448 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-02 17:58:46 +0100 dr r267284 : #i10000# rebase errors 2009-02-02 17:52:21 +0100 dr r267282 : #i10000# rebase errors 2009-02-02 17:35:58 +0100 dr r267280 : #i10000# rebase errors 2009-02-02 15:58:04 +0100 dr r267274 : CWS-TOOLING: rebase CWS dr67 to trunk@267171 (milestone: DEV300:m41) 2009-02-02 09:16:32 +0100 dr r267247 : #i97873# typo 2009-01-30 17:09:09 +0100 dr r267215 : #i97873# import numeric grouping settings for datapilot fields from BIFF5/BIFF8/OOBIN/OOXML 2009-01-29 16:36:24 +0100 dr r267154 : #i97873# import datapilot discrete grouping from BIFF5/BIFF8/OOBIN/OOXLS 2009-01-29 16:33:37 +0100 dr r267152 : #i97873# do not kill _all_ the other group fields when writing back DataPilotField::GroupInfo property 2009-01-29 14:15:45 +0100 dr r267133 : #i93839# remove ScChengeTrack::Load and ::Store, adapt xls export filter 2009-01-28 13:30:37 +0100 dr r267056 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-28 12:09:05 +0100 dr r267051 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-27 16:13:58 +0100 dr r267005 : #i97873# minor changes in DataPilot API implementation as preparation for additional changes needed for OOX import filter 2009-01-27 10:08:01 +0100 dr r266961 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-27 10:06:50 +0100 dr r266960 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-23 12:52:31 +0100 dr r266808 : #i97873# DP documentation extended 2009-01-21 20:07:15 +0100 dr r266702 : #i97873# this trivial patch adds BIFF5/BIFF8 pivot table import to the oox filter 2009-01-20 16:06:23 +0100 dr r266592 : select BIFF filter via env.var 2009-01-16 18:51:01 +0100 dr r266452 : #i97873# import page fields 2009-01-16 15:05:36 +0100 dr r266420 : #i97873# field item settings (collapsed/hidden), settings of hidden fields 2009-01-15 16:01:17 +0100 dr r266377 : #i97873# import OOXML7/OOBIN7 autoshow settings 2009-01-14 15:24:27 +0100 dr r266310 : #i97873# import auto show settings generated by MSO2003 2009-01-14 12:29:44 +0100 dr r266281 : #i97873# set global dp settings 2009-01-13 15:04:30 +0100 dr r266229 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-13 14:46:50 +0100 dr r266225 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-12 15:04:22 +0100 dr r266161 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 15:03:42 +0100 dr r266160 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 14:57:33 +0100 dr r266159 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-12 14:52:43 +0100 dr r266158 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-09 16:34:55 +0100 dr r266098 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 16:32:16 +0100 dr r266097 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 12:02:39 +0100 dr r266072 : #i97623# RTL handling changed after CWS rtlcontrols 2009-01-09 09:48:53 +0100 dr r266050 : #i158444# SXLI must be filled completely before starting CONTINUE 2009-01-08 18:50:08 +0100 dr r266032 : #158444# allow to disable dump of record positions 2009-01-08 15:46:45 +0100 dr r266020 : #i97873# data layout field handling 2009-01-08 15:45:45 +0100 dr r266019 : #i97873# data layout field handling 2009-01-08 15:42:25 +0100 dr r266018 : #i97873# data layout field handling 2009-01-02 17:28:32 +0100 dr r265844 : #i10000# unxmacxi warning 2009-01-02 16:59:13 +0100 dr r265842 : #i10000# rebase corrections 2009-01-02 16:44:44 +0100 dr r265838 : #i10000# rebase corrections 2009-01-02 11:32:44 +0100 dr r265834 : CWS-TOOLING: rebase CWS dr67 to trunk@265758 (milestone: DEV300:m38) 2008-12-29 16:55:40 +0100 dr r265822 : more pivot table import, field layout settings 2008-12-29 14:27:35 +0100 dr r265817 : more pivot table import, additions for data field settings 2008-12-26 14:39:21 +0100 dr r265805 : updates 2008-12-19 16:31:39 +0100 dr r265734 : typo 2008-12-19 16:30:00 +0100 dr r265733 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:43 +0100 dr r265732 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:07 +0100 dr r265731 : add API for sequence of DP field subtotal functions 2008-12-18 18:07:58 +0100 dr r265710 : #i96758# try to cache row default formatting and apply it at row ranges instead of single rows 2008-12-18 16:00:25 +0100 dr r265698 : more additions to pivot import 2008-12-17 13:38:19 +0100 dr r265599 : do not assert HIDDEN orientation 2008-12-12 13:51:29 +0100 dr r265415 : minor typos 2008-12-12 10:15:04 +0100 dr r265394 : pivot cache import extended to XLSB, added creation of cache data for missing/external sheets 2008-12-04 13:16:16 +0100 dr r264837 : #i96860# remove old dumper files 2008-12-04 12:17:38 +0100 dr r264834 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-04 12:16:38 +0100 dr r264833 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-03 14:51:05 +0100 dr r264784 : #i10000# warnings 2008-12-03 14:32:46 +0100 dr r264778 : #i10000# warning 2008-12-03 11:28:38 +0100 dr r264758 : #i96758# ignore zero-sized objects 2008-12-03 10:09:34 +0100 dr r264748 : #i96758# change ::oox::Property(Set|Map) keys to sal_Int32 property identifiers, to save construction of property names 2008-12-01 16:09:02 +0100 dr r264615 : #i96758# headerdoc 2008-12-01 14:49:04 +0100 dr r264607 : #i96758# import performance of formatted documents 2008-11-26 17:08:15 +0100 dr r264424 : make it more simple 2008-11-26 16:31:41 +0100 dr r264419 : c:crossesAt is for crossing axis, not for own axis. This is different to BIFF 2008-11-26 13:55:55 +0100 dr r264382 : #i86346# import of MissingValueTreatment from XLSX 2008-11-26 12:49:38 +0100 dr r264370 : #i86346# import/export of MissingValueTreatment from/to XLS 2008-11-25 17:48:59 +0100 dr r264320 : update row height with single progress bar when using 'IsAdjustHeightEnabled' document property 2008-11-25 17:24:26 +0100 dr r264319 : #i96438# disable importing comment text until API is fixed 2008-11-25 17:11:30 +0100 dr r264318 : #i90124# set control tooltips, patch from npower 2008-11-25 15:09:28 +0100 dr r264309 : #i94028# #i94991# update drawing objects when changing row height 2008-11-24 15:21:35 +0100 dr r264224 : prevent ::rtl::OUString::copy assertion 2008-11-24 15:19:39 +0100 dr r264223 : #i95183# #158573# handle non-ascii characters in sheet names in OOXML import 2008-11-24 12:54:30 +0100 dr r264221 : #i94157# support ESC key to leave full-screen in page preview 2008-11-21 18:15:17 +0100 dr r264165 : #i90360# disable chart perspective if it is set to 0 2008-11-21 18:14:41 +0100 dr r264164 : #i90360# disable chart perspective if it is set to 0 2008-11-21 17:43:26 +0100 dr r264155 : #i96140# missing parenth 2008-11-21 17:36:35 +0100 dr r264154 : #i96438# first steps of note import 2008-11-20 15:15:03 +0100 dr r264059 : get rid of ContextWrapper 2008-11-18 11:39:52 +0100 dr r263755 : #i78476# moved to CWS dr67
2009-04-22 10:06:26 +00:00
if( !in().isEof() && (in().tell() == nRecPos) )
2008-09-30 13:51:36 +00:00
dumpRawBinary( mnRecSize, false );
else
dumpRemainingTo( nRecPos + mnRecSize );
2008-01-17 07:06:10 +00:00
}
}
2008-09-30 13:51:36 +00:00
void RecordObjectBase::implWriteExtHeader()
2008-01-17 07:06:10 +00:00
{
}
2008-09-30 13:51:36 +00:00
void RecordObjectBase::implDumpRecordBody()
{
}
void RecordObjectBase::constructRecObjBase( const BinaryInputStreamRef& rxBaseStrm, const String& rRecNames, const String& rSimpleRecs )
{
mxBaseStrm = rxBaseStrm;
maRecNames = rRecNames;
maSimpleRecs = rSimpleRecs;
mnRecPos = mnRecId = mnRecSize = 0;
CWS-TOOLING: integrate CWS dr67 2009-04-08 13:23:56 +0200 dr r270638 : #i100534# reverted 2009-04-08 10:14:55 +0200 dr r270621 : CWS-TOOLING: rebase CWS dr67 to trunk@270033 (milestone: DEV300:m45) 2009-04-07 21:06:33 +0200 dr r270610 : #i100534# sc does not link in debug mode 2009-03-12 11:20:09 +0100 dr r269375 : #i10000# wae 2009-03-11 19:43:55 +0100 dr r269351 : #i10000# adjust oox namespace ids according to oox/inc/oox/core/namespaces.hxx 2009-03-11 15:38:52 +0100 dr r269339 : CWS-TOOLING: rebase CWS dr67 to trunk@269297 (milestone: DEV300:m43) 2009-02-27 15:20:21 +0100 dr r268598 : CWS-TOOLING: rebase CWS dr67 to trunk@268395 (milestone: DEV300:m42) 2009-02-19 13:32:17 +0100 dr r268277 : moved hf parser into page settings 2009-02-19 12:25:15 +0100 dr r268272 : renamed some structs according to chart filter 2009-02-16 15:51:31 +0100 dr r267823 : #i97873# import autosort settings from BIFF8/OOBIN/OOXML 2009-02-06 17:09:29 +0100 dr r267477 : #i97873# minor changes 2009-02-06 16:38:56 +0100 dr r267473 : #i97873# import date grouping settings from BIFF5/BIFF8/OOBIN/OOXML 2009-02-06 16:38:11 +0100 dr r267472 : #i97873# check min/max/step of passed GroupInfo 2009-02-06 16:35:13 +0100 dr r267471 : #i97873# more doc for createDategroup() 2009-02-06 13:53:42 +0100 dr r267459 : #i97873# make XDataPilotGrouping::createDateGroup() implementation working and robust against wrong input data 2009-02-06 13:52:16 +0100 dr r267458 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-06 12:35:49 +0100 dr r267453 : fix other IDLC warnings in sheet module 2009-02-06 12:05:19 +0100 dr r267448 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-02 17:58:46 +0100 dr r267284 : #i10000# rebase errors 2009-02-02 17:52:21 +0100 dr r267282 : #i10000# rebase errors 2009-02-02 17:35:58 +0100 dr r267280 : #i10000# rebase errors 2009-02-02 15:58:04 +0100 dr r267274 : CWS-TOOLING: rebase CWS dr67 to trunk@267171 (milestone: DEV300:m41) 2009-02-02 09:16:32 +0100 dr r267247 : #i97873# typo 2009-01-30 17:09:09 +0100 dr r267215 : #i97873# import numeric grouping settings for datapilot fields from BIFF5/BIFF8/OOBIN/OOXML 2009-01-29 16:36:24 +0100 dr r267154 : #i97873# import datapilot discrete grouping from BIFF5/BIFF8/OOBIN/OOXLS 2009-01-29 16:33:37 +0100 dr r267152 : #i97873# do not kill _all_ the other group fields when writing back DataPilotField::GroupInfo property 2009-01-29 14:15:45 +0100 dr r267133 : #i93839# remove ScChengeTrack::Load and ::Store, adapt xls export filter 2009-01-28 13:30:37 +0100 dr r267056 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-28 12:09:05 +0100 dr r267051 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-27 16:13:58 +0100 dr r267005 : #i97873# minor changes in DataPilot API implementation as preparation for additional changes needed for OOX import filter 2009-01-27 10:08:01 +0100 dr r266961 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-27 10:06:50 +0100 dr r266960 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-23 12:52:31 +0100 dr r266808 : #i97873# DP documentation extended 2009-01-21 20:07:15 +0100 dr r266702 : #i97873# this trivial patch adds BIFF5/BIFF8 pivot table import to the oox filter 2009-01-20 16:06:23 +0100 dr r266592 : select BIFF filter via env.var 2009-01-16 18:51:01 +0100 dr r266452 : #i97873# import page fields 2009-01-16 15:05:36 +0100 dr r266420 : #i97873# field item settings (collapsed/hidden), settings of hidden fields 2009-01-15 16:01:17 +0100 dr r266377 : #i97873# import OOXML7/OOBIN7 autoshow settings 2009-01-14 15:24:27 +0100 dr r266310 : #i97873# import auto show settings generated by MSO2003 2009-01-14 12:29:44 +0100 dr r266281 : #i97873# set global dp settings 2009-01-13 15:04:30 +0100 dr r266229 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-13 14:46:50 +0100 dr r266225 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-12 15:04:22 +0100 dr r266161 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 15:03:42 +0100 dr r266160 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 14:57:33 +0100 dr r266159 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-12 14:52:43 +0100 dr r266158 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-09 16:34:55 +0100 dr r266098 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 16:32:16 +0100 dr r266097 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 12:02:39 +0100 dr r266072 : #i97623# RTL handling changed after CWS rtlcontrols 2009-01-09 09:48:53 +0100 dr r266050 : #i158444# SXLI must be filled completely before starting CONTINUE 2009-01-08 18:50:08 +0100 dr r266032 : #158444# allow to disable dump of record positions 2009-01-08 15:46:45 +0100 dr r266020 : #i97873# data layout field handling 2009-01-08 15:45:45 +0100 dr r266019 : #i97873# data layout field handling 2009-01-08 15:42:25 +0100 dr r266018 : #i97873# data layout field handling 2009-01-02 17:28:32 +0100 dr r265844 : #i10000# unxmacxi warning 2009-01-02 16:59:13 +0100 dr r265842 : #i10000# rebase corrections 2009-01-02 16:44:44 +0100 dr r265838 : #i10000# rebase corrections 2009-01-02 11:32:44 +0100 dr r265834 : CWS-TOOLING: rebase CWS dr67 to trunk@265758 (milestone: DEV300:m38) 2008-12-29 16:55:40 +0100 dr r265822 : more pivot table import, field layout settings 2008-12-29 14:27:35 +0100 dr r265817 : more pivot table import, additions for data field settings 2008-12-26 14:39:21 +0100 dr r265805 : updates 2008-12-19 16:31:39 +0100 dr r265734 : typo 2008-12-19 16:30:00 +0100 dr r265733 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:43 +0100 dr r265732 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:07 +0100 dr r265731 : add API for sequence of DP field subtotal functions 2008-12-18 18:07:58 +0100 dr r265710 : #i96758# try to cache row default formatting and apply it at row ranges instead of single rows 2008-12-18 16:00:25 +0100 dr r265698 : more additions to pivot import 2008-12-17 13:38:19 +0100 dr r265599 : do not assert HIDDEN orientation 2008-12-12 13:51:29 +0100 dr r265415 : minor typos 2008-12-12 10:15:04 +0100 dr r265394 : pivot cache import extended to XLSB, added creation of cache data for missing/external sheets 2008-12-04 13:16:16 +0100 dr r264837 : #i96860# remove old dumper files 2008-12-04 12:17:38 +0100 dr r264834 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-04 12:16:38 +0100 dr r264833 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-03 14:51:05 +0100 dr r264784 : #i10000# warnings 2008-12-03 14:32:46 +0100 dr r264778 : #i10000# warning 2008-12-03 11:28:38 +0100 dr r264758 : #i96758# ignore zero-sized objects 2008-12-03 10:09:34 +0100 dr r264748 : #i96758# change ::oox::Property(Set|Map) keys to sal_Int32 property identifiers, to save construction of property names 2008-12-01 16:09:02 +0100 dr r264615 : #i96758# headerdoc 2008-12-01 14:49:04 +0100 dr r264607 : #i96758# import performance of formatted documents 2008-11-26 17:08:15 +0100 dr r264424 : make it more simple 2008-11-26 16:31:41 +0100 dr r264419 : c:crossesAt is for crossing axis, not for own axis. This is different to BIFF 2008-11-26 13:55:55 +0100 dr r264382 : #i86346# import of MissingValueTreatment from XLSX 2008-11-26 12:49:38 +0100 dr r264370 : #i86346# import/export of MissingValueTreatment from/to XLS 2008-11-25 17:48:59 +0100 dr r264320 : update row height with single progress bar when using 'IsAdjustHeightEnabled' document property 2008-11-25 17:24:26 +0100 dr r264319 : #i96438# disable importing comment text until API is fixed 2008-11-25 17:11:30 +0100 dr r264318 : #i90124# set control tooltips, patch from npower 2008-11-25 15:09:28 +0100 dr r264309 : #i94028# #i94991# update drawing objects when changing row height 2008-11-24 15:21:35 +0100 dr r264224 : prevent ::rtl::OUString::copy assertion 2008-11-24 15:19:39 +0100 dr r264223 : #i95183# #158573# handle non-ascii characters in sheet names in OOXML import 2008-11-24 12:54:30 +0100 dr r264221 : #i94157# support ESC key to leave full-screen in page preview 2008-11-21 18:15:17 +0100 dr r264165 : #i90360# disable chart perspective if it is set to 0 2008-11-21 18:14:41 +0100 dr r264164 : #i90360# disable chart perspective if it is set to 0 2008-11-21 17:43:26 +0100 dr r264155 : #i96140# missing parenth 2008-11-21 17:36:35 +0100 dr r264154 : #i96438# first steps of note import 2008-11-20 15:15:03 +0100 dr r264059 : get rid of ContextWrapper 2008-11-18 11:39:52 +0100 dr r263755 : #i78476# moved to CWS dr67
2009-04-22 10:06:26 +00:00
if( InputObjectBase::implIsValid() )
mbShowRecPos = cfg().getBoolOption( "show-record-position", true );
2008-09-30 13:51:36 +00:00
}
void RecordObjectBase::writeHeader()
{
MultiItemsGuard aMultiGuard( out() );
writeEmptyItem( "REC" );
CWS-TOOLING: integrate CWS dr67 2009-04-08 13:23:56 +0200 dr r270638 : #i100534# reverted 2009-04-08 10:14:55 +0200 dr r270621 : CWS-TOOLING: rebase CWS dr67 to trunk@270033 (milestone: DEV300:m45) 2009-04-07 21:06:33 +0200 dr r270610 : #i100534# sc does not link in debug mode 2009-03-12 11:20:09 +0100 dr r269375 : #i10000# wae 2009-03-11 19:43:55 +0100 dr r269351 : #i10000# adjust oox namespace ids according to oox/inc/oox/core/namespaces.hxx 2009-03-11 15:38:52 +0100 dr r269339 : CWS-TOOLING: rebase CWS dr67 to trunk@269297 (milestone: DEV300:m43) 2009-02-27 15:20:21 +0100 dr r268598 : CWS-TOOLING: rebase CWS dr67 to trunk@268395 (milestone: DEV300:m42) 2009-02-19 13:32:17 +0100 dr r268277 : moved hf parser into page settings 2009-02-19 12:25:15 +0100 dr r268272 : renamed some structs according to chart filter 2009-02-16 15:51:31 +0100 dr r267823 : #i97873# import autosort settings from BIFF8/OOBIN/OOXML 2009-02-06 17:09:29 +0100 dr r267477 : #i97873# minor changes 2009-02-06 16:38:56 +0100 dr r267473 : #i97873# import date grouping settings from BIFF5/BIFF8/OOBIN/OOXML 2009-02-06 16:38:11 +0100 dr r267472 : #i97873# check min/max/step of passed GroupInfo 2009-02-06 16:35:13 +0100 dr r267471 : #i97873# more doc for createDategroup() 2009-02-06 13:53:42 +0100 dr r267459 : #i97873# make XDataPilotGrouping::createDateGroup() implementation working and robust against wrong input data 2009-02-06 13:52:16 +0100 dr r267458 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-06 12:35:49 +0100 dr r267453 : fix other IDLC warnings in sheet module 2009-02-06 12:05:19 +0100 dr r267448 : #i97873# fix and extend IDL doc for datapilot grouping 2009-02-02 17:58:46 +0100 dr r267284 : #i10000# rebase errors 2009-02-02 17:52:21 +0100 dr r267282 : #i10000# rebase errors 2009-02-02 17:35:58 +0100 dr r267280 : #i10000# rebase errors 2009-02-02 15:58:04 +0100 dr r267274 : CWS-TOOLING: rebase CWS dr67 to trunk@267171 (milestone: DEV300:m41) 2009-02-02 09:16:32 +0100 dr r267247 : #i97873# typo 2009-01-30 17:09:09 +0100 dr r267215 : #i97873# import numeric grouping settings for datapilot fields from BIFF5/BIFF8/OOBIN/OOXML 2009-01-29 16:36:24 +0100 dr r267154 : #i97873# import datapilot discrete grouping from BIFF5/BIFF8/OOBIN/OOXLS 2009-01-29 16:33:37 +0100 dr r267152 : #i97873# do not kill _all_ the other group fields when writing back DataPilotField::GroupInfo property 2009-01-29 14:15:45 +0100 dr r267133 : #i93839# remove ScChengeTrack::Load and ::Store, adapt xls export filter 2009-01-28 13:30:37 +0100 dr r267056 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-28 12:09:05 +0100 dr r267051 : #i98397# enhance DataPilot API: allow to rename groups and items in a group field 2009-01-27 16:13:58 +0100 dr r267005 : #i97873# minor changes in DataPilot API implementation as preparation for additional changes needed for OOX import filter 2009-01-27 10:08:01 +0100 dr r266961 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-27 10:06:50 +0100 dr r266960 : #i97873# changing orientation of a DP field moves it to last position in new dimension 2009-01-23 12:52:31 +0100 dr r266808 : #i97873# DP documentation extended 2009-01-21 20:07:15 +0100 dr r266702 : #i97873# this trivial patch adds BIFF5/BIFF8 pivot table import to the oox filter 2009-01-20 16:06:23 +0100 dr r266592 : select BIFF filter via env.var 2009-01-16 18:51:01 +0100 dr r266452 : #i97873# import page fields 2009-01-16 15:05:36 +0100 dr r266420 : #i97873# field item settings (collapsed/hidden), settings of hidden fields 2009-01-15 16:01:17 +0100 dr r266377 : #i97873# import OOXML7/OOBIN7 autoshow settings 2009-01-14 15:24:27 +0100 dr r266310 : #i97873# import auto show settings generated by MSO2003 2009-01-14 12:29:44 +0100 dr r266281 : #i97873# set global dp settings 2009-01-13 15:04:30 +0100 dr r266229 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-13 14:46:50 +0100 dr r266225 : #i98029# SdrGroupObj does not remember predefined bounding rectangle anymore 2009-01-12 15:04:22 +0100 dr r266161 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 15:03:42 +0100 dr r266160 : #i97873# remove misleading hasDataLayoutField() 2009-01-12 14:57:33 +0100 dr r266159 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-12 14:52:43 +0100 dr r266158 : #i97900# reverted previous change, adjusted code to new EnableRTL() behaviour 2009-01-09 16:34:55 +0100 dr r266098 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 16:32:16 +0100 dr r266097 : #i97900# RTL handling in TabBar changed with CWS rtlcontrols 2009-01-09 12:02:39 +0100 dr r266072 : #i97623# RTL handling changed after CWS rtlcontrols 2009-01-09 09:48:53 +0100 dr r266050 : #i158444# SXLI must be filled completely before starting CONTINUE 2009-01-08 18:50:08 +0100 dr r266032 : #158444# allow to disable dump of record positions 2009-01-08 15:46:45 +0100 dr r266020 : #i97873# data layout field handling 2009-01-08 15:45:45 +0100 dr r266019 : #i97873# data layout field handling 2009-01-08 15:42:25 +0100 dr r266018 : #i97873# data layout field handling 2009-01-02 17:28:32 +0100 dr r265844 : #i10000# unxmacxi warning 2009-01-02 16:59:13 +0100 dr r265842 : #i10000# rebase corrections 2009-01-02 16:44:44 +0100 dr r265838 : #i10000# rebase corrections 2009-01-02 11:32:44 +0100 dr r265834 : CWS-TOOLING: rebase CWS dr67 to trunk@265758 (milestone: DEV300:m38) 2008-12-29 16:55:40 +0100 dr r265822 : more pivot table import, field layout settings 2008-12-29 14:27:35 +0100 dr r265817 : more pivot table import, additions for data field settings 2008-12-26 14:39:21 +0100 dr r265805 : updates 2008-12-19 16:31:39 +0100 dr r265734 : typo 2008-12-19 16:30:00 +0100 dr r265733 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:43 +0100 dr r265732 : add API for sequence of DP field subtotal functions 2008-12-19 16:29:07 +0100 dr r265731 : add API for sequence of DP field subtotal functions 2008-12-18 18:07:58 +0100 dr r265710 : #i96758# try to cache row default formatting and apply it at row ranges instead of single rows 2008-12-18 16:00:25 +0100 dr r265698 : more additions to pivot import 2008-12-17 13:38:19 +0100 dr r265599 : do not assert HIDDEN orientation 2008-12-12 13:51:29 +0100 dr r265415 : minor typos 2008-12-12 10:15:04 +0100 dr r265394 : pivot cache import extended to XLSB, added creation of cache data for missing/external sheets 2008-12-04 13:16:16 +0100 dr r264837 : #i96860# remove old dumper files 2008-12-04 12:17:38 +0100 dr r264834 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-04 12:16:38 +0100 dr r264833 : #i96858# XTO broken, if textbox is empty but contains formatting 2008-12-03 14:51:05 +0100 dr r264784 : #i10000# warnings 2008-12-03 14:32:46 +0100 dr r264778 : #i10000# warning 2008-12-03 11:28:38 +0100 dr r264758 : #i96758# ignore zero-sized objects 2008-12-03 10:09:34 +0100 dr r264748 : #i96758# change ::oox::Property(Set|Map) keys to sal_Int32 property identifiers, to save construction of property names 2008-12-01 16:09:02 +0100 dr r264615 : #i96758# headerdoc 2008-12-01 14:49:04 +0100 dr r264607 : #i96758# import performance of formatted documents 2008-11-26 17:08:15 +0100 dr r264424 : make it more simple 2008-11-26 16:31:41 +0100 dr r264419 : c:crossesAt is for crossing axis, not for own axis. This is different to BIFF 2008-11-26 13:55:55 +0100 dr r264382 : #i86346# import of MissingValueTreatment from XLSX 2008-11-26 12:49:38 +0100 dr r264370 : #i86346# import/export of MissingValueTreatment from/to XLS 2008-11-25 17:48:59 +0100 dr r264320 : update row height with single progress bar when using 'IsAdjustHeightEnabled' document property 2008-11-25 17:24:26 +0100 dr r264319 : #i96438# disable importing comment text until API is fixed 2008-11-25 17:11:30 +0100 dr r264318 : #i90124# set control tooltips, patch from npower 2008-11-25 15:09:28 +0100 dr r264309 : #i94028# #i94991# update drawing objects when changing row height 2008-11-24 15:21:35 +0100 dr r264224 : prevent ::rtl::OUString::copy assertion 2008-11-24 15:19:39 +0100 dr r264223 : #i95183# #158573# handle non-ascii characters in sheet names in OOXML import 2008-11-24 12:54:30 +0100 dr r264221 : #i94157# support ESC key to leave full-screen in page preview 2008-11-21 18:15:17 +0100 dr r264165 : #i90360# disable chart perspective if it is set to 0 2008-11-21 18:14:41 +0100 dr r264164 : #i90360# disable chart perspective if it is set to 0 2008-11-21 17:43:26 +0100 dr r264155 : #i96140# missing parenth 2008-11-21 17:36:35 +0100 dr r264154 : #i96438# first steps of note import 2008-11-20 15:15:03 +0100 dr r264059 : get rid of ContextWrapper 2008-11-18 11:39:52 +0100 dr r263755 : #i78476# moved to CWS dr67
2009-04-22 10:06:26 +00:00
if( mbShowRecPos && mxBaseStrm->isSeekable() )
2008-09-30 13:51:36 +00:00
writeShortHexItem( "pos", mnRecPos, "CONV-DEC" );
writeShortHexItem( "size", mnRecSize, "CONV-DEC" );
ItemGuard aItem( out(), "id" );
out().writeShortHex( mnRecId );
addNameToItem( mnRecId, "CONV-DEC" );
addNameToItem( mnRecId, maRecNames );
}
2008-01-17 07:06:10 +00:00
// ============================================================================
2008-09-30 13:51:36 +00:00
void SequenceRecordObjectBase::construct(
const ObjectBase& rParent, const BinaryInputStreamRef& rxBaseStrm, const ::rtl::OUString& rSysFileName,
const BinaryInputStreamRef& rxRecStrm, const String& rRecNames, const String& rSimpleRecs )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
RecordObjectBase::construct( rParent, rxBaseStrm, rSysFileName, rxRecStrm, rRecNames, rSimpleRecs );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void SequenceRecordObjectBase::construct( const OutputObjectBase& rParent,
const BinaryInputStreamRef& rxBaseStrm, const BinaryInputStreamRef& rxRecStrm,
const String& rRecNames, const String& rSimpleRecs )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
RecordObjectBase::construct( rParent, rxBaseStrm, rxRecStrm, rRecNames, rSimpleRecs );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void SequenceRecordObjectBase::construct( const ObjectBase& rParent,
const BinaryInputStreamRef& rxBaseStrm, const ::rtl::OUString& rSysFileName,
const String& rRecNames, const String& rSimpleRecs )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
BinaryInputStreamRef xRecStrm( new SequenceInputStream( *mxRecData ) );
RecordObjectBase::construct( rParent, rxBaseStrm, rSysFileName, xRecStrm, rRecNames, rSimpleRecs );
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void SequenceRecordObjectBase::construct( const OutputObjectBase& rParent,
const BinaryInputStreamRef& rxBaseStrm, const String& rRecNames, const String& rSimpleRecs )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
BinaryInputStreamRef xRecStrm( new SequenceInputStream( *mxRecData ) );
RecordObjectBase::construct( rParent, rxBaseStrm, xRecStrm, rRecNames, rSimpleRecs );
}
bool SequenceRecordObjectBase::implStartRecord( BinaryInputStream& rBaseStrm, sal_Int64& ornRecPos, sal_Int64& ornRecId, sal_Int64& ornRecSize )
{
bool bValid = true;
if( rBaseStrm.isSeekable() )
{
ornRecPos = rBaseStrm.tell();
// do not try to overread seekable streams, may cause assertions
bValid = ornRecPos < rBaseStrm.getLength();
}
// read the record header
if( bValid )
bValid = implReadRecordHeader( rBaseStrm, ornRecId, ornRecSize ) && !rBaseStrm.isEof() && (0 <= ornRecSize) && (ornRecSize <= 0x00100000);
// read record contents into data sequence
if( bValid )
{
sal_Int32 nRecSize = static_cast< sal_Int32 >( ornRecSize );
mxRecData->realloc( nRecSize );
bValid = (nRecSize == 0) || (rBaseStrm.readData( *mxRecData, nRecSize ) == nRecSize);
in().seekToStart();
}
return bValid;
}
// ============================================================================
// ============================================================================
DumperBase::~DumperBase()
{
}
bool DumperBase::isImportEnabled() const
{
return !isValid() || cfg().isImportEnabled();
2008-01-17 07:06:10 +00:00
}
2008-09-30 13:51:36 +00:00
void DumperBase::construct( const ConfigRef& rxConfig )
2008-01-17 07:06:10 +00:00
{
2008-09-30 13:51:36 +00:00
if( isValid( rxConfig ) && rxConfig->isDumperEnabled() )
ObjectBase::construct( rxConfig );
2008-01-17 07:06:10 +00:00
}
// ============================================================================
// ============================================================================
} // namespace dump
} // namespace oox
#endif